[LTP] [PATCH 1/1] device-drivers: Fix module build on kernel >= 5.18
Ricardo B. Marliere
rbm@suse.com
Thu Jan 9 11:56:26 CET 2025
Hi Petr!
On 27 Dec 24 17:24, Petr Vorel wrote:
> Similarly to 82e38a1f24 wrap <linux/genhd.h> with ifndef. This fixes
> module build on 5.18 and newer where <linux/genhd.h> was merged into
> <linux/blkdev.h>.
>
> NOTE: ltp_acpi_cmds.c kept unfixed because acpi_bus_get_device() removed
> in 5.18 in ac2a3feefad54 ("ACPI: bus: Eliminate acpi_bus_get_device()")
> (replaced by acpi_fetch_acpi_dev().)
>
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
Reviewed-by: Ricardo B. Marliere <rbm@suse.com>
Thanks,
- Ricardo.
> ---
> Hi,
>
> there are more things to fix:
> nlsTest.c:40:10: fatal error: linux/autoconf.h: No such file or directory
>
> I need more time for ltp_acpi_cmds.c. Hopefully ACPI_SUCCESS(status)
> could be just replaced with detecting if returned device is not null.
>
> Kind regards,
> Petr
>
> +++ testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
> @@ -36,7 +36,9 @@
> #include <linux/ioctl.h>
> #include <linux/pm.h>
> #include <linux/acpi.h>
> +#ifndef DISK_NAME_LEN
> # include <linux/genhd.h>
> +#endif
> #include <linux/dmi.h>
> #include <linux/nls.h>
>
> @@ -130,8 +132,13 @@ static void get_sysfs_path(acpi_handle handle)
> kfree(sysfs_path);
> sysfs_path = NULL;
>
> +#ifndef DISK_NAME_LEN
> status = acpi_bus_get_device(handle, &device);
> if (ACPI_SUCCESS(status))
> +#else
> + device = acpi_fetch_acpi_dev(handle);
> +#endif
> + if (!device)
> sysfs_path = kobject_get_path(&device->dev.kobj, GFP_KERNEL);
> }
>
> @@ -399,9 +406,15 @@ static int acpi_test_bus(void)
> if (acpi_failure(status, "acpi_get_handle"))
> return 1;
>
> +#ifndef DISK_NAME_LEN
> prk_alert("TEST -- acpi_bus_get_device");
> status = acpi_bus_get_device(bus_handle, &device);
> if (acpi_failure(status, "acpi_bus_get_device"))
> +#else
> + prk_alert("TEST -- acpi_fetch_acpi_dev");
> + device = acpi_fetch_acpi_dev(bus_handle);
> + if (!device)
> +#endif
> return 1;
>
> prk_alert("TEST -- acpi_bus_update_power ");
>
>
> testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c | 3 ++-
> .../kernel/device-drivers/block/block_dev_kernel/test_genhd.c | 4 +++-
> testcases/kernel/device-drivers/include/includeTest.c | 4 +++-
> testcases/kernel/device-drivers/nls/nlsTest.c | 4 +++-
> testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c | 4 +++-
> 5 files changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c b/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
> index d12dd6b94c..85ee6e3488 100644
> --- a/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
> +++ b/testcases/kernel/device-drivers/acpi/ltp_acpi_cmds.c
> @@ -36,10 +36,11 @@
> #include <linux/ioctl.h>
> #include <linux/pm.h>
> #include <linux/acpi.h>
> -#include <linux/genhd.h>
> +# include <linux/genhd.h>
> #include <linux/dmi.h>
> #include <linux/nls.h>
>
> +
> #include "ltp_acpi.h"
>
> MODULE_AUTHOR("Martin Ridgeway <mridge@us.ibm.com>");
> diff --git a/testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c b/testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c
> index d34a236b41..225840525c 100644
> --- a/testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c
> +++ b/testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c
> @@ -13,7 +13,9 @@
> */
>
> #include <linux/module.h>
> -#include <linux/genhd.h>
> +#ifndef DISK_NAME_LEN
> +# include <linux/genhd.h>
> +#endif
>
> MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
> MODULE_DESCRIPTION("Test block drivers");
> diff --git a/testcases/kernel/device-drivers/include/includeTest.c b/testcases/kernel/device-drivers/include/includeTest.c
> index d5b6fe229d..5f9a8f244a 100644
> --- a/testcases/kernel/device-drivers/include/includeTest.c
> +++ b/testcases/kernel/device-drivers/include/includeTest.c
> @@ -33,7 +33,9 @@
> #include <linux/module.h>
> #include <linux/init.h>
> #include <linux/pm.h>
> -#include <linux/genhd.h>
> +#ifndef DISK_NAME_LEN
> +# include <linux/genhd.h>
> +#endif
> #include <linux/in.h>
> #include <asm/types.h>
> #include <linux/lockd/bind.h>
> diff --git a/testcases/kernel/device-drivers/nls/nlsTest.c b/testcases/kernel/device-drivers/nls/nlsTest.c
> index f0c39ab9fe..c6813a1cb1 100644
> --- a/testcases/kernel/device-drivers/nls/nlsTest.c
> +++ b/testcases/kernel/device-drivers/nls/nlsTest.c
> @@ -31,7 +31,9 @@
> #include <linux/module.h>
> #include <linux/init.h>
> #include <linux/pm.h>
> -#include <linux/genhd.h>
> +#ifndef DISK_NAME_LEN
> +# include <linux/genhd.h>
> +#endif
> #include <linux/version.h>
> #include <linux/string.h>
> #include <linux/autoconf.h>
> diff --git a/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c b/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
> index 0a9cd40ebb..fd58eb9b94 100644
> --- a/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
> +++ b/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
> @@ -43,7 +43,9 @@
> #include <linux/errno.h>
> #include <linux/types.h>
> #include <linux/vmalloc.h>
> -#include <linux/genhd.h>
> +#ifndef DISK_NAME_LEN
> +# include <linux/genhd.h>
> +#endif
> #include <linux/blkdev.h>
> #include <linux/buffer_head.h>
>
> --
> 2.45.2
>
> .../device-drivers/block/block_dev_kernel/test_genhd.c | 5 ++++-
> testcases/kernel/device-drivers/include/includeTest.c | 5 ++++-
> testcases/kernel/device-drivers/nls/nlsTest.c | 6 ++++--
> testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c | 4 +++-
> 4 files changed, 15 insertions(+), 5 deletions(-)
>
> diff --git a/testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c b/testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c
> index d34a236b41..e2f687c173 100644
> --- a/testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c
> +++ b/testcases/kernel/device-drivers/block/block_dev_kernel/test_genhd.c
> @@ -13,7 +13,10 @@
> */
>
> #include <linux/module.h>
> -#include <linux/genhd.h>
> +#include <linux/blkdev.h>
> +#ifndef DISK_NAME_LEN
> +# include <linux/genhd.h>
> +#endif
>
> MODULE_AUTHOR("Márton Németh <nm127@freemail.hu>");
> MODULE_DESCRIPTION("Test block drivers");
> diff --git a/testcases/kernel/device-drivers/include/includeTest.c b/testcases/kernel/device-drivers/include/includeTest.c
> index d5b6fe229d..1340abbc40 100644
> --- a/testcases/kernel/device-drivers/include/includeTest.c
> +++ b/testcases/kernel/device-drivers/include/includeTest.c
> @@ -33,7 +33,10 @@
> #include <linux/module.h>
> #include <linux/init.h>
> #include <linux/pm.h>
> -#include <linux/genhd.h>
> +#include <linux/blkdev.h>
> +#ifndef DISK_NAME_LEN
> +# include <linux/genhd.h>
> +#endif
> #include <linux/in.h>
> #include <asm/types.h>
> #include <linux/lockd/bind.h>
> diff --git a/testcases/kernel/device-drivers/nls/nlsTest.c b/testcases/kernel/device-drivers/nls/nlsTest.c
> index f0c39ab9fe..510f7d2528 100644
> --- a/testcases/kernel/device-drivers/nls/nlsTest.c
> +++ b/testcases/kernel/device-drivers/nls/nlsTest.c
> @@ -31,12 +31,14 @@
> #include <linux/module.h>
> #include <linux/init.h>
> #include <linux/pm.h>
> -#include <linux/genhd.h>
> +#include <linux/blkdev.h>
> +#ifndef DISK_NAME_LEN
> +# include <linux/genhd.h>
> +#endif
> #include <linux/version.h>
> #include <linux/string.h>
> #include <linux/autoconf.h>
> #include <linux/nls.h>
> -#include <linux/blkdev.h>
>
> #ifdef CONFIG_KMOD
> #include <linux/kmod.h>
> diff --git a/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c b/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
> index 0a9cd40ebb..afadfe7b96 100644
> --- a/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
> +++ b/testcases/kernel/device-drivers/tbio/tbio_kernel/ltp_tbio.c
> @@ -43,8 +43,10 @@
> #include <linux/errno.h>
> #include <linux/types.h>
> #include <linux/vmalloc.h>
> -#include <linux/genhd.h>
> #include <linux/blkdev.h>
> +#ifndef DISK_NAME_LEN
> +# include <linux/genhd.h>
> +#endif
> #include <linux/buffer_head.h>
>
> #include "tbio.h"
> --
> 2.45.2
>
More information about the ltp
mailing list