From f6e070f87e38da26ecd6e3632065597aa677810c Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 9 Oct 2023 13:12:50 +0100 Subject: [PATCH] spi: aurix: Use conftest Rather than using kernel version checks to determine which kernel APIs to use, add the necessary tests to the conftest script to determine which kernel APIs are present in the kernel. This is beneficial for working with 3rd party Linux kernels that may have back-ported upstream changes into their kernel and so the kernel version checks do not work. Bug 4221847 Change-Id: I159cd7d5feca050c8a8014d9c2a3b43e8974fdfd Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2993807 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/spi/spi-aurix-tegra.c | 10 ++++++---- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 18 ++++++++++++++++++ 3 files changed, 25 insertions(+), 4 deletions(-) diff --git a/drivers/spi/spi-aurix-tegra.c b/drivers/spi/spi-aurix-tegra.c index 331f8862..f9b91280 100644 --- a/drivers/spi/spi-aurix-tegra.c +++ b/drivers/spi/spi-aurix-tegra.c @@ -1,5 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 -// Copyright (c) 2022, NVIDIA CORPORATION. All rights reserved. +// Copyright (c) 2022-2023, NVIDIA CORPORATION. All rights reserved. + +#include #include #include @@ -244,10 +246,10 @@ ret: spin_lock_irqsave(&aurix_data->lock, flags); aurix_data->exited = true; spin_unlock_irqrestore(&aurix_data->lock, flags); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 17, 0) - complete_and_exit(NULL, err); -#else +#if defined(NV_KTHREAD_COMPLETE_AND_EXIT_PRESENT) /* Linux v5.17 */ kthread_complete_and_exit(NULL, err); +#else + complete_and_exit(NULL, err); #endif } diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 83d15749..e6663cb6 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -114,6 +114,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += ethtool_ops_get_set_ringparam_has_ringpara NV_CONFTEST_FUNCTION_COMPILE_TESTS += get_user_pages NV_CONFTEST_FUNCTION_COMPILE_TESTS += iio_dev_opaque_has_mlock NV_CONFTEST_FUNCTION_COMPILE_TESTS += iommu_map_has_gfp_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += kthread_complete_and_exit NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_set_tso_max_size NV_CONFTEST_FUNCTION_COMPILE_TESTS += netif_napi_add_weight NV_CONFTEST_FUNCTION_COMPILE_TESTS += pde_data diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index d4687968..d8867862 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -6861,6 +6861,24 @@ compile_test() { compile_check_conftest "$CODE" "NV_IIO_DEV_OPAQUE_HAS_LOCK" "" "types" ;; + kthread_complete_and_exit) + # + # Determine if function kthread_complete_and_exit() is present. + # + # This function was added in Linux v5.17 by commit cead18552660 + # ("exit: Rename complete_and_exit to kthread_complete_and_exit"). + # + CODE=" + #include + void conftest_kthread_complete_and_exit(void) + { + kthread_complete_and_exit(); + } + " + + compile_check_conftest "$CODE" "NV_KTHREAD_COMPLETE_AND_EXIT_PRESENT" "" "functions" + ;; + register_shrinker_has_fmt_arg) # # Determine if the 'register_shrinker' function