Loading drivers/thermal/of-thermal.c +10 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,12 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz, if (!data->senps || !data->senps->ops->get_temp) return -EINVAL; if (data->mode == THERMAL_DEVICE_DISABLED) { *temp = tz->tzp->tracks_low ? THERMAL_TEMP_INVALID_LOW : THERMAL_TEMP_INVALID; return 0; } return data->senps->ops->get_temp(data->senps->sensor_data, temp); } Loading Loading @@ -507,6 +513,8 @@ static int of_thermal_aggregate_trip_types(struct thermal_zone_device *tz, head = &data->senps->first_tz; list_for_each_entry(data, head, list) { zone = data->tzd; if (data->mode == THERMAL_DEVICE_DISABLED) continue; for (trip = 0; trip < data->ntrips; trip++) { of_thermal_get_trip_type(zone, trip, &type); if (!(BIT(type) & trip_type_mask)) Loading Loading @@ -570,6 +578,8 @@ void of_thermal_handle_trip(struct thermal_zone_device *tz) head = &data->senps->first_tz; list_for_each_entry(data, head, list) { zone = data->tzd; if (data->mode == THERMAL_DEVICE_DISABLED) continue; thermal_zone_device_update(zone, THERMAL_EVENT_UNSPECIFIED); } } Loading drivers/thermal/thermal_core.c +23 −2 Original line number Diff line number Diff line Loading @@ -594,7 +594,8 @@ static void update_temperature(struct thermal_zone_device *tz) mutex_unlock(&tz->lock); trace_thermal_temperature(tz); if (tz->last_temperature == THERMAL_TEMP_INVALID) if (tz->last_temperature == THERMAL_TEMP_INVALID || tz->last_temperature == THERMAL_TEMP_INVALID_LOW) dev_dbg(&tz->device, "last_temperature N/A, current_temperature=%d\n", tz->temperature); else Loading Loading @@ -688,6 +689,26 @@ mode_show(struct device *dev, struct device_attribute *attr, char *buf) : "disabled"); } static int thermal_zone_device_clear(struct thermal_zone_device *tz) { struct thermal_instance *pos; int ret = 0; ret = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED); mutex_lock(&tz->lock); thermal_zone_device_reset(tz); list_for_each_entry(pos, &tz->thermal_instances, tz_node) { pos->target = THERMAL_NO_TARGET; mutex_lock(&pos->cdev->lock); pos->cdev->updated = false; /* cdev needs update */ mutex_unlock(&pos->cdev->lock); thermal_cdev_update(pos->cdev); } mutex_unlock(&tz->lock); return ret; } static ssize_t mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) Loading @@ -701,7 +722,7 @@ mode_store(struct device *dev, struct device_attribute *attr, if (!strncmp(buf, "enabled", sizeof("enabled") - 1)) result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED); else if (!strncmp(buf, "disabled", sizeof("disabled") - 1)) result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED); result = thermal_zone_device_clear(tz); else result = -EINVAL; Loading include/linux/thermal.h +6 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,12 @@ /* use value, which < 0K, to indicate an invalid/uninitialized temperature */ #define THERMAL_TEMP_INVALID -274000 /* * use a high value for low temp tracking zone, * to indicate an invalid/uninitialized temperature */ #define THERMAL_TEMP_INVALID_LOW 274000 /* Unit conversion macros */ #define DECI_KELVIN_TO_CELSIUS(t) ({ \ long _t = (t); \ Loading Loading
drivers/thermal/of-thermal.c +10 −0 Original line number Diff line number Diff line Loading @@ -193,6 +193,12 @@ static int of_thermal_get_temp(struct thermal_zone_device *tz, if (!data->senps || !data->senps->ops->get_temp) return -EINVAL; if (data->mode == THERMAL_DEVICE_DISABLED) { *temp = tz->tzp->tracks_low ? THERMAL_TEMP_INVALID_LOW : THERMAL_TEMP_INVALID; return 0; } return data->senps->ops->get_temp(data->senps->sensor_data, temp); } Loading Loading @@ -507,6 +513,8 @@ static int of_thermal_aggregate_trip_types(struct thermal_zone_device *tz, head = &data->senps->first_tz; list_for_each_entry(data, head, list) { zone = data->tzd; if (data->mode == THERMAL_DEVICE_DISABLED) continue; for (trip = 0; trip < data->ntrips; trip++) { of_thermal_get_trip_type(zone, trip, &type); if (!(BIT(type) & trip_type_mask)) Loading Loading @@ -570,6 +578,8 @@ void of_thermal_handle_trip(struct thermal_zone_device *tz) head = &data->senps->first_tz; list_for_each_entry(data, head, list) { zone = data->tzd; if (data->mode == THERMAL_DEVICE_DISABLED) continue; thermal_zone_device_update(zone, THERMAL_EVENT_UNSPECIFIED); } } Loading
drivers/thermal/thermal_core.c +23 −2 Original line number Diff line number Diff line Loading @@ -594,7 +594,8 @@ static void update_temperature(struct thermal_zone_device *tz) mutex_unlock(&tz->lock); trace_thermal_temperature(tz); if (tz->last_temperature == THERMAL_TEMP_INVALID) if (tz->last_temperature == THERMAL_TEMP_INVALID || tz->last_temperature == THERMAL_TEMP_INVALID_LOW) dev_dbg(&tz->device, "last_temperature N/A, current_temperature=%d\n", tz->temperature); else Loading Loading @@ -688,6 +689,26 @@ mode_show(struct device *dev, struct device_attribute *attr, char *buf) : "disabled"); } static int thermal_zone_device_clear(struct thermal_zone_device *tz) { struct thermal_instance *pos; int ret = 0; ret = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED); mutex_lock(&tz->lock); thermal_zone_device_reset(tz); list_for_each_entry(pos, &tz->thermal_instances, tz_node) { pos->target = THERMAL_NO_TARGET; mutex_lock(&pos->cdev->lock); pos->cdev->updated = false; /* cdev needs update */ mutex_unlock(&pos->cdev->lock); thermal_cdev_update(pos->cdev); } mutex_unlock(&tz->lock); return ret; } static ssize_t mode_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) Loading @@ -701,7 +722,7 @@ mode_store(struct device *dev, struct device_attribute *attr, if (!strncmp(buf, "enabled", sizeof("enabled") - 1)) result = tz->ops->set_mode(tz, THERMAL_DEVICE_ENABLED); else if (!strncmp(buf, "disabled", sizeof("disabled") - 1)) result = tz->ops->set_mode(tz, THERMAL_DEVICE_DISABLED); result = thermal_zone_device_clear(tz); else result = -EINVAL; Loading
include/linux/thermal.h +6 −0 Original line number Diff line number Diff line Loading @@ -52,6 +52,12 @@ /* use value, which < 0K, to indicate an invalid/uninitialized temperature */ #define THERMAL_TEMP_INVALID -274000 /* * use a high value for low temp tracking zone, * to indicate an invalid/uninitialized temperature */ #define THERMAL_TEMP_INVALID_LOW 274000 /* Unit conversion macros */ #define DECI_KELVIN_TO_CELSIUS(t) ({ \ long _t = (t); \ Loading