From d95c0d0add22289801d964c15368b139d29e897a Mon Sep 17 00:00:00 2001 From: Jon Hunter Date: Fri, 12 Apr 2024 11:36:13 +0100 Subject: [PATCH] thermal: Fix build for Linux v6.10 In Linux v6.10, commit b1ae92dcfa8e ("thermal: core: Make struct thermal_zone_device definition internal") made the structure 'thermal_zone_device' internal and so the 'devdata' member is no longer directly accessible. The function thermal_zone_device_priv() was added in Linux v6.4 for retrieving the 'devdata' and so update the various thermal drivers to use this function if present. Bug 4593750 Change-Id: Ic53de9bbd5459c99a3ac26759aa8a966cd775fe5 Signed-off-by: Jon Hunter Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3123221 Tested-by: mobile promotions Reviewed-by: mobile promotions --- drivers/thermal/max77851_thermal.c | 8 ++++++-- drivers/thermal/pex9749-thermal.c | 6 +++++- scripts/conftest/Makefile | 1 + scripts/conftest/conftest.sh | 17 +++++++++++++++++ 4 files changed, 29 insertions(+), 3 deletions(-) diff --git a/drivers/thermal/max77851_thermal.c b/drivers/thermal/max77851_thermal.c index 2b4d5289..6a236bf7 100644 --- a/drivers/thermal/max77851_thermal.c +++ b/drivers/thermal/max77851_thermal.c @@ -44,14 +44,18 @@ struct max77851_therm_info { int irq_tjalarm2; }; -#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) +#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) /* Linux v6.1 */ static int max77851_thermal_read_temp(struct thermal_zone_device *data, int *temp) #else static int max77851_thermal_read_temp(void *data, int *temp) #endif { -#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) +#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) /* Linux v6.1 */ +#if defined(NV_THERMAL_ZONE_DEVICE_PRIV_PRESENT) /* Linux v6.4 */ + struct max77851_therm_info *thermal = thermal_zone_device_priv(data); +#else struct max77851_therm_info *thermal = data->devdata; +#endif #else struct max77851_therm_info *thermal = data; #endif diff --git a/drivers/thermal/pex9749-thermal.c b/drivers/thermal/pex9749-thermal.c index 0a6d3a4d..8c16394f 100644 --- a/drivers/thermal/pex9749-thermal.c +++ b/drivers/thermal/pex9749-thermal.c @@ -110,10 +110,14 @@ static int pex9749_calc_temp(u16 v) return temp; } -#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) +#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) /* Linux v6.1 */ static int pex9749_get_temp(struct thermal_zone_device *tz, int *temp) { +#if defined(NV_THERMAL_ZONE_DEVICE_PRIV_PRESENT) /* Linux v6.4 */ + struct pex9749_priv *priv = thermal_zone_device_priv(tz); +#else struct pex9749_priv *priv = tz->devdata; +#endif #else static int pex9749_get_temp(void *data, int *temp) { diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index c17b849e..0c1e56a8 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -160,6 +160,7 @@ NV_CONFTEST_FUNCTION_COMPILE_TESTS += tc_taprio_qopt_offload_struct_has_cmd NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra264_chip_id NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_dev_iommu_get_stream_id NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_ivc_struct_has_iosys_map +NV_CONFTEST_FUNCTION_COMPILE_TESTS += thermal_zone_device_priv NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_send_xchar_has_u8_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_write_has_u8_ptr_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_set_termios_has_const_ktermios_arg diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index c548baff..900cce48 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -7665,6 +7665,23 @@ compile_test() { compile_check_conftest "$CODE" "NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP" "" "types" ;; + thermal_zone_device_priv) + # + # Determine if the function thermal_zone_device_priv() is present. + # + # Commit a6ff3c002146 ("thermal/core: Add a thermal zone 'devdata' + # accessor") added function thermal_zone_device_priv() in Linux + # v6.4. + # + CODE=" + #include + void conftest_thermal_zone_device_priv(void) { + thermal_zone_device_priv(); + }" + + compile_check_conftest "$CODE" "NV_THERMAL_ZONE_DEVICE_PRIV_PRESENT" "" "functions" + ;; + tegra_dev_iommu_get_stream_id) # # Determine if the function tegra_dev_iommu_get_stream_id is present.