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 <jonathanh@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nv-oot/+/3123221
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
This commit is contained in:
Jon Hunter
2024-04-12 11:36:13 +01:00
committed by mobile promotions
parent 32ed59d81b
commit d95c0d0add
4 changed files with 29 additions and 3 deletions

View File

@@ -44,14 +44,18 @@ struct max77851_therm_info {
int irq_tjalarm2; 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) static int max77851_thermal_read_temp(struct thermal_zone_device *data, int *temp)
#else #else
static int max77851_thermal_read_temp(void *data, int *temp) static int max77851_thermal_read_temp(void *data, int *temp)
#endif #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; struct max77851_therm_info *thermal = data->devdata;
#endif
#else #else
struct max77851_therm_info *thermal = data; struct max77851_therm_info *thermal = data;
#endif #endif

View File

@@ -110,10 +110,14 @@ static int pex9749_calc_temp(u16 v)
return temp; 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) 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; struct pex9749_priv *priv = tz->devdata;
#endif
#else #else
static int pex9749_get_temp(void *data, int *temp) static int pex9749_get_temp(void *data, int *temp)
{ {

View File

@@ -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 += tegra264_chip_id
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tegra_dev_iommu_get_stream_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 += 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_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_write_has_u8_ptr_arg
NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_set_termios_has_const_ktermios_arg NV_CONFTEST_FUNCTION_COMPILE_TESTS += tty_operations_struct_set_termios_has_const_ktermios_arg

View File

@@ -7665,6 +7665,23 @@ compile_test() {
compile_check_conftest "$CODE" "NV_TEGRA_IVC_STRUCT_HAS_IOSYS_MAP" "" "types" 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 <linux/thermal.h>
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) tegra_dev_iommu_get_stream_id)
# #
# Determine if the function tegra_dev_iommu_get_stream_id is present. # Determine if the function tegra_dev_iommu_get_stream_id is present.