[LTP] [PATCH] device-drivers/acpi/ltp_acpi_cmds: Fix build errors
Tiezhu Yang
yangtiezhu@loongson.cn
Fri Jul 11 10:01:55 CEST 2025
There exist the following errors when building LTP:
ltp_acpi_cmds.c:39:10: fatal error: linux/genhd.h: No such file or directory
ltp_acpi_cmds.c:131:18: error: implicit declaration of function 'acpi_bus_get_device'
ltp_acpi_cmds.c:400:18: error: implicit declaration of function 'acpi_bus_get_device'
For the first error:
This is because genhd.h has been removed in the Linux kernel, the contents
of genhd.h was folded into blkdev.h [1]. Since blkdev.h has been included
in the C file, just remove unused include genhd.h to fix the build error.
For the second and third errors:
This is because acpi_bus_get_device() has been droped in the Linux kernel,
in order to fix the build errors, just replace acpi_bus_get_device() with
acpi_fetch_acpi_dev() like the kernel commit [2].
[1] https://git.kernel.org/torvalds/c/322cbb50de71
[2] https://git.kernel.org/torvalds/c/ac2a3feefad5
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c b/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
index d12dd6b94..b2d46e1a8 100644
--- a/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
+++ b/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
@@ -36,7 +36,6 @@
#include <linux/ioctl.h>
#include <linux/pm.h>
#include <linux/acpi.h>
-#include <linux/genhd.h>
#include <linux/dmi.h>
#include <linux/nls.h>
@@ -123,14 +122,13 @@ static void get_crs_object(acpi_handle handle)
static void get_sysfs_path(acpi_handle handle)
{
- acpi_status status;
struct acpi_device *device;
kfree(sysfs_path);
sysfs_path = NULL;
- status = acpi_bus_get_device(handle, &device);
- if (ACPI_SUCCESS(status))
+ device = acpi_fetch_acpi_dev(handle);
+ if (device)
sysfs_path = kobject_get_path(&device->dev.kobj, GFP_KERNEL);
}
@@ -398,9 +396,9 @@ static int acpi_test_bus(void)
if (acpi_failure(status, "acpi_get_handle"))
return 1;
- prk_alert("TEST -- acpi_bus_get_device");
- status = acpi_bus_get_device(bus_handle, &device);
- if (acpi_failure(status, "acpi_bus_get_device"))
+ prk_alert("TEST -- acpi_fetch_acpi_dev");
+ device = acpi_fetch_acpi_dev(bus_handle);
+ if (!device)
return 1;
prk_alert("TEST -- acpi_bus_update_power ");
--
2.42.0
More information about the ltp
mailing list