From 45cee87fa724bb679575a01a5093f4aa4729a5e7 Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Tue, 21 Nov 2023 16:04:16 +0000 Subject: [PATCH] gpu/host1x: Use conftest for Linux v6.3 Use conftest to determine if the uevent() function pointer in the bus_type structure has a const dev argument. This fixes the build for Linux kernels prior to Linux v6.3 that include the upstream change that changed the arguments to this function. Bug 4014315 Change-Id: I1553e08c951be9dd27141c273bf91be38dd954a6 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3019964 (cherry picked from commit 5fe2e2aacc1e83be52fa4cf60a9cc409b7ecfbc5) Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3020430 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/gpu/host1x/bus.c | 5 +++-- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 20 ++++++++++++++++++++ 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index fe8e12e6..3777585e 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -4,6 +4,8 @@ * Copyright (C) 2012-2013, NVIDIA Corporation */ +#include + #include #include #include @@ -11,7 +13,6 @@ #include #include #include -#include #include "bus.h" #include "dev.h" @@ -339,7 +340,7 @@ static int host1x_device_match(struct device *dev, struct device_driver *drv) return strcmp(dev_name(dev), drv->name) == 0; } -#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0) +#if defined(NV_BUS_TYPE_STRUCT_UEVENT_HAS_CONST_DEV_ARG) /* Linux v6.3 */ static int host1x_device_uevent(const struct device *dev, #else static int host1x_device_uevent(struct device *dev, diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 462c1a5a..fc5f942f 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -95,6 +95,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += blk_mq_destroy_queue NV_CONFTEST_FUNCTION_COMPILE_TESTS += block_device_operations_open_has_gendisk_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += block_device_operations_release_has_no_mode_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += bus_type_struct_remove_has_int_return_type +NV_CONFTEST_FUNCTION_COMPILE_TESTS += bus_type_struct_uevent_has_const_dev_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += class_create_has_no_owner_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += class_struct_devnode_has_const_dev_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += define_semaphore_has_number_arg diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index e686765c..133a9fee 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -6461,6 +6461,26 @@ compile_test() { compile_check_conftest "$CODE" "NV_BUS_TYPE_STRUCT_REMOVE_HAS_INT_RETURN_TYPE" "" "types" ;; + bus_type_struct_uevent_has_const_dev_arg) + # + # Determine if the 'uevent' callback from the 'bus_type' structure + # has a const 'struct dev' argument. + # + # Commit 2a81ada32f0e ("driver core: make struct bus_type.uevent() + # take a const *") updated the arguments to the uevent callback + # function in Linux v6.3. + # + CODE=" + #include + int conftest_bus_type_struct_remove_has_int_return_type(const struct device *dev, + struct kobj_uevent_env *env, + struct bus_type *bus) { + return bus->uevent(dev, env); + }" + + compile_check_conftest "$CODE" "NV_BUS_TYPE_STRUCT_UEVENT_HAS_CONST_DEV_ARG" "" "types" + ;; + class_create_has_no_owner_arg) # # Determine if the class_create() function has the 'owner' argument.