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 <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/2989732
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2023-10-02 13:52:08 +01:00
committed by mobile promotions
parent ed130f099a
commit 86dafc35bb
4 changed files with 24 additions and 0 deletions

View File

@@ -30,6 +30,7 @@
#include <linux/ptrace.h> #include <linux/ptrace.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/serial_core.h> #include <linux/serial_core.h>
#include <linux/semaphore.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/timer.h> #include <linux/timer.h>

View File

@@ -11,11 +11,17 @@
* more details. * more details.
*/ */
#include <nvidia/conftest.h>
#include <linux/version.h> #include <linux/version.h>
#include "wch_common.h" #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); static DEFINE_SEMAPHORE(ser_port_sem);
#endif
#define WCH_HIGH_BITS_OFFSET ((sizeof(long) - sizeof(int)) * 8) #define WCH_HIGH_BITS_OFFSET ((sizeof(long) - sizeof(int)) * 8)
#define wch_ser_users(state) ((state)->count + ((state)->info ? (state)->info->blocked_open : 0)) #define wch_ser_users(state) ((state)->count + ((state)->info ? (state)->info->blocked_open : 0))

View File

@@ -90,6 +90,7 @@ endef
NV_CONFTEST_FUNCTION_COMPILE_TESTS += bus_type_struct_remove_has_int_return_type 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 += 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 += devm_thermal_of_zone_register
NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_aperture_remove_framebuffers_has_drm_driver_arg 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 NV_CONFTEST_FUNCTION_COMPILE_TESTS += drm_driver_struct_has_irq_enabled_arg

View File

@@ -6332,6 +6332,22 @@ compile_test() {
compile_check_conftest "$CODE" "NV_CLASS_STRUCT_DEVNODE_HAS_CONST_DEV_ARG" "" "types" 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 <linux/semaphore.h>
DEFINE_SEMAPHORE(my_sem, 1);"
compile_check_conftest "$CODE" "NV_DEFINE_SEMAPHORE_HAS_NUMBER_ARG" "" "types"
;;
devm_thermal_of_zone_register) devm_thermal_of_zone_register)
# #
# Determine whether devm_thermal_of_zone_register is present. # Determine whether devm_thermal_of_zone_register is present.