--- zzzz-none-000/linux-4.9.231/drivers/thermal/of-thermal.c 2020-07-22 07:10:54.000000000 +0000 +++ falcon-5530-730/linux-4.9.231/drivers/thermal/of-thermal.c 2022-08-31 08:19:49.000000000 +0000 @@ -31,6 +31,7 @@ #include #include #include +#include #include "thermal_core.h" @@ -440,6 +441,20 @@ return tzd; } +#define MILLI_TO_DEZI_CELSIUS(x) ((x)/100) + +int read_temp_callback(void *avm_power_handle, void *context, int *value) +{ + struct thermal_zone_device *tzd = context; + int ret; + + ret = thermal_zone_get_temp(tzd, value); + if (!ret) + *value = MILLI_TO_DEZI_CELSIUS(*value); + + return ret; +} + /** * thermal_zone_of_sensor_register - registers a sensor to a DT thermal zone * @dev: a valid struct device pointer of a sensor device. Must contain @@ -526,6 +541,9 @@ of_node_put(sensor_np); of_node_put(np); + if (!IS_ERR(tzd)) + tzd->avm_power_handle = TemperaturSensorRegister(tzd->type, + read_temp_callback, tzd); return tzd; } EXPORT_SYMBOL_GPL(thermal_zone_of_sensor_register); @@ -553,6 +571,9 @@ if (!dev || !tzd || !tzd->devdata) return; + if (tzd->avm_power_handle) + TemperaturSensorDeregister(tzd->avm_power_handle); + tz = tzd->devdata; /* no __thermal_zone, nothing to be done */