From 9974fda1d2358e130c4ed985cdd3183dec275afb Mon Sep 17 00:00:00 2001 From: Laxman Dewangan Date: Mon, 18 Dec 2023 11:19:17 +0000 Subject: [PATCH] spi: Use conftest to find return type of .remove of spi_driver struct Use conftest to determine the return type of .remove() of struct spi_driver is int or void type instead of kernel version. The return type got changed with commit a0386bba7093 ("spi: make remove callback a void function") in Linux 5.18 Bug 4387902 Change-Id: I644fe0610a76fbc4cea547c3295670599ae919bc Signed-off-by: Laxman Dewangan Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3037038 GVS: Gerrit_Virtual_Submit --- drivers/spi/spi-aurix-tegra.c | 3 +-- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 17 +++++++++++++++++ 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi-aurix-tegra.c b/drivers/spi/spi-aurix-tegra.c index f9b91280..45a69d29 100644 --- a/drivers/spi/spi-aurix-tegra.c +++ b/drivers/spi/spi-aurix-tegra.c @@ -8,7 +8,6 @@ #include #include //#include -#include #include #define AURIX 0x3 @@ -372,7 +371,7 @@ static int aurix_tegra_start_kthread(struct device *dev) /* * remove, shutdown, suspend, resume functions */ -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0) +#if defined(NV_SPI_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT) /* Linux 5.18 */ static int aurix_tegra_spi_remove(struct spi_device *spi) { return aurix_tegra_stop_kthread(&spi->dev); diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index eefc6996..b86252fa 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -147,6 +147,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_dai_ops_struct_has_probe NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_of_get_dai_name_has_index_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += snd_soc_rtd_to_codec NV_CONFTEST_FUNCTION_COMPILE_TESTS += simple_util_dai_init +NV_CONFTEST_FUNCTION_COMPILE_TESTS += spi_driver_struct_remove_return_type_int NV_CONFTEST_FUNCTION_COMPILE_TESTS += tc_taprio_qopt_offload_struct_has_cmd NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_dev_iommu_get_stream_id NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_ivc_struct_has_iosys_map diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 526b32d2..8ef61485 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7414,6 +7414,23 @@ compile_test() { compile_check_conftest "$CODE" "NV_ASOC_SIMPLE_RENAMED_SIMPLE" "" "functions" ;; + spi_driver_struct_remove_return_type_int) + # + # Determine if return type of .remove function of struct spi_driver is int or void. + # + # The return type of .remove is changed with commit a0386bba7093 ("spi: make remove + # callback a void function") in Linux 5.18. + # + CODE=" + #define _LINUX_EFI_H + #include + int conftest_spi_driver_struct_remove_return_type_int(struct spi_driver *spid) { + return spid->remove(NULL); + }" + + compile_check_conftest "$CODE" "NV_SPI_DRIVER_STRUCT_REMOVE_RETURN_TYPE_INT" "" "types" + ;; + tc_taprio_qopt_offload_struct_has_cmd) # # Determine if struct tc_taprio_qopt_offload has a member named cmd