From 86dafc35bbf2f71544c7a36cb057ef664de383fb Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Mon, 2 Oct 2023 13:52:08 +0100 Subject: [PATCH] tty: serial: ch384: Fix build for Linux v6.4 In Linux v6.4, the macro DEFINE_SEMAPHORE was updated and this breaks the build for the ch384 serial driver. Add a new test to the conftest script that checks if the macro DEFINE_SEMAPHORE takes a number argument and use the definition created by conftest to select which version of the macro is used. Bug 4183168 Bug 4221847 Change-Id: Ie1bcb95b07e792c70fa52e22465bdf565dc456af Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2989732 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/tty/serial/wch_35x/wch_common.h | 1 + drivers/tty/serial/wch_35x/wch_serial.c | 6 ++++++ scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 16 ++++++++++++++++ 4 files changed, 24 insertions(+) diff --git a/drivers/tty/serial/wch_35x/wch_common.h b/drivers/tty/serial/wch_35x/wch_common.h index 4de18085..9c1fc103 100644 --- a/drivers/tty/serial/wch_35x/wch_common.h +++ b/drivers/tty/serial/wch_35x/wch_common.h @@ -30,6 +30,7 @@ #include #include #include +#include #include #include diff --git a/drivers/tty/serial/wch_35x/wch_serial.c b/drivers/tty/serial/wch_35x/wch_serial.c index 45a17404..44721695 100644 --- a/drivers/tty/serial/wch_35x/wch_serial.c +++ b/drivers/tty/serial/wch_35x/wch_serial.c @@ -11,11 +11,17 @@ * more details. */ +#include + #include #include "wch_common.h" +#if defined(NV_DEFINE_SEMAPHORE_HAS_NUMBER_ARG) +static DEFINE_SEMAPHORE(ser_port_sem, 1); +#else static DEFINE_SEMAPHORE(ser_port_sem); +#endif #define WCH_HIGH_BITS_OFFSET ((sizeof(long) - sizeof(int)) * 8) #define wch_ser_users(state) ((state)->count + ((state)->info ? (state)->info->blocked_open : 0)) diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index aa29dfa2..6c503579 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -90,6 +90,7 @@ endef NV_CONFTEST_FUNCTION_COMPILE_TESTS += bus_type_struct_remove_has_int_return_type NV_CONFTEST_FUNCTION_COMPILE_TESTS += class_struct_devnode_has_const_dev_arg +NV_CONFTEST_FUNCTION_COMPILE_TESTS += define_semaphore_has_number_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_thermal_of_zone_register NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_framebuffers_has_drm_driver_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_driver_struct_has_irq_enabled_arg diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 48904402..a229fb7c 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -6332,6 +6332,22 @@ compile_test() { compile_check_conftest "$CODE" "NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG" "" "types" ;; + define_semaphore_has_number_arg) + # + # Determine if the macro DEFINE_SEMAPHORE has a number argument. + # + # In Linux v6.4, 48380368dec1 ("Change DEFINE_SEMAPHORE() to + # take a number argument") updated the macro DEFINE_SEMAPHORE to + # take a number argument. + # + CODE=" + #include + + DEFINE_SEMAPHORE(my_sem, 1);" + + compile_check_conftest "$CODE" "NV_DEFINE_SEMAPHORE_HAS_NUMBER_ARG" "" "types" + ;; + devm_thermal_of_zone_register) # # Determine whether devm_thermal_of_zone_register is present.