Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

thermal: of: implement .set_trips for device tree thermal zones

This patch implements .set_trips for device tree thermal zones.
As the hardware-tracked trip points is supported by thermal core patch[0].

patch[0]
"thermal: Add support for hardware-tracked trip points".

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Caesar Wang <wxt@rock-chips.com>
Cc: Zhang Rui <rui.zhang@intel.com>
Cc: Eduardo Valentin <edubezval@gmail.com>
Reviewed-by: Javi Merino <javi.merino@arm.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>

authored by

Sascha Hauer and committed by
Zhang Rui
826386e7 060c034a

+23
+19
drivers/thermal/of-thermal.c
··· 101 101 return data->ops->get_temp(data->sensor_data, temp); 102 102 } 103 103 104 + static int of_thermal_set_trips(struct thermal_zone_device *tz, 105 + int low, int high) 106 + { 107 + struct __thermal_zone *data = tz->devdata; 108 + 109 + if (!data->ops || !data->ops->set_trips) 110 + return -EINVAL; 111 + 112 + return data->ops->set_trips(data->sensor_data, low, high); 113 + } 114 + 104 115 /** 105 116 * of_thermal_get_ntrips - function to export number of available trip 106 117 * points. ··· 438 427 439 428 tzd->ops->get_temp = of_thermal_get_temp; 440 429 tzd->ops->get_trend = of_thermal_get_trend; 430 + 431 + /* 432 + * The thermal zone core will calculate the window if they have set the 433 + * optional set_trips pointer. 434 + */ 435 + if (ops->set_trips) 436 + tzd->ops->set_trips = of_thermal_set_trips; 437 + 441 438 tzd->ops->set_emul_temp = of_thermal_set_emul_temp; 442 439 mutex_unlock(&tzd->lock); 443 440
+4
include/linux/thermal.h
··· 340 340 * 341 341 * Optional: 342 342 * @get_trend: a pointer to a function that reads the sensor temperature trend. 343 + * @set_trips: a pointer to a function that sets a temperature window. When 344 + * this window is left the driver must inform the thermal core via 345 + * thermal_zone_device_update. 343 346 * @set_emul_temp: a pointer to a function that sets sensor emulated 344 347 * temperature. 345 348 * @set_trip_temp: a pointer to a function that sets the trip temperature on ··· 351 348 struct thermal_zone_of_device_ops { 352 349 int (*get_temp)(void *, int *); 353 350 int (*get_trend)(void *, long *); 351 + int (*set_trips)(void *, int, int); 354 352 int (*set_emul_temp)(void *, int); 355 353 int (*set_trip_temp)(void *, int, int); 356 354 };