diff --git a/drivers/thermal/max77851_thermal.c b/drivers/thermal/max77851_thermal.c index c44c7ddd..2b4d5289 100644 --- a/drivers/thermal/max77851_thermal.c +++ b/drivers/thermal/max77851_thermal.c @@ -4,6 +4,8 @@ * Junction temperature thermal driver for Maxim Max77851. */ +#include + #include #include #include @@ -13,7 +15,6 @@ #include #include #include -#include #include @@ -43,16 +44,16 @@ struct max77851_therm_info { int irq_tjalarm2; }; -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) -static int max77851_thermal_read_temp(void *data, int *temp) -#else +#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) 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 LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - struct max77851_therm_info *thermal = data; -#else +#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) struct max77851_therm_info *thermal = data->devdata; +#else + struct max77851_therm_info *thermal = data; #endif unsigned int val; int ret; @@ -74,10 +75,10 @@ static int max77851_thermal_read_temp(struct thermal_zone_device *data, int *tem return 0; } -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) -static const struct thermal_zone_of_device_ops max77851_thermal_ops = { -#else +#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) static const struct thermal_zone_device_ops max77851_thermal_ops = { +#else +static const struct thermal_zone_of_device_ops max77851_thermal_ops = { #endif .get_temp = max77851_thermal_read_temp, }; @@ -166,11 +167,11 @@ static int max77851_thermal_probe(struct platform_device *pdev) max77851_thermal_init(thermal); -#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 16, 0) - thermal->tz_device = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, +#if defined(NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT) + thermal->tz_device = devm_thermal_of_zone_register(&pdev->dev, 0, thermal, &max77851_thermal_ops); #else - thermal->tz_device = devm_thermal_of_zone_register(&pdev->dev, 0, + thermal->tz_device = devm_thermal_zone_of_sensor_register(&pdev->dev, 0, thermal, &max77851_thermal_ops); #endif if (IS_ERR(thermal->tz_device)) { diff --git a/scripts/conftest/Makefile b/scripts/conftest/Makefile index 5863a050..fc5491dc 100644 --- a/scripts/conftest/Makefile +++ b/scripts/conftest/Makefile @@ -88,7 +88,7 @@ endef # provided by the module-specific Kbuild files. # -NV_CONFTEST_FUNCTION_COMPILE_TESTS ?= +NV_CONFTEST_FUNCTION_COMPILE_TESTS += devm_thermal_of_zone_register NV_CONFTEST_GENERIC_COMPILE_TESTS ?= NV_CONFTEST_MACRO_COMPILE_TESTS ?= NV_CONFTEST_SYMBOL_COMPILE_TESTS ?= diff --git a/scripts/conftest/conftest.sh b/scripts/conftest/conftest.sh index 73f11bd2..aa2480a9 100755 --- a/scripts/conftest/conftest.sh +++ b/scripts/conftest/conftest.sh @@ -6293,6 +6293,23 @@ compile_test() { compile_check_conftest "$CODE" "NV_CRYPTO_PRESENT" "" "symbols" ;; + devm_thermal_of_zone_register) + # + # Determine whether devm_thermal_of_zone_register is present. + # + # devm_thermal_of_zone_register was added in commit 3fd6d6e2b4e8 + # ("thermal/of: Rework the thermal device tree initialization") in + # v6.1 (2022-08-17) + # + CODE=" + #include + void conftest_devm_thermal_of_zone_register(void) { + devm_thermal_of_zone_register(); + }" + + compile_check_conftest "$CODE" "NV_DEVM_THERMAL_OF_ZONE_REGISTER_PRESENT" "" "functions" + ;; + # When adding a new conftest entry, please use the correct format for # specifying the relevant upstream Linux kernel commit. #