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

thermal/drivers/thermal_of: Add change_mode ops support for thermal_of sensor

The sensor driver which register through thermal_of interface doesn't
have an option to get thermal zone mode change notification from
thermal core.

Add support for change_mode ops in thermal_of interface so that sensor
driver can use this ops for mode change notification.

Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
Link: https://lore.kernel.org/r/1646767586-31908-1-git-send-email-quic_manafm@quicinc.com
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>

authored by

Manaf Meethalavalappu Pallikunhi and committed by
Daniel Lezcano
bf70c577 106e0121

+15
+12
drivers/thermal/thermal_of.c
··· 203 203 return data->ops->get_trend(data->sensor_data, trip, trend); 204 204 } 205 205 206 + static int of_thermal_change_mode(struct thermal_zone_device *tz, 207 + enum thermal_device_mode mode) 208 + { 209 + struct __thermal_zone *data = tz->devdata; 210 + 211 + return data->ops->change_mode(data->sensor_data, mode); 212 + } 213 + 206 214 static int of_thermal_bind(struct thermal_zone_device *thermal, 207 215 struct thermal_cooling_device *cdev) 208 216 { ··· 416 408 if (ops->set_emul_temp) 417 409 tzd->ops->set_emul_temp = of_thermal_set_emul_temp; 418 410 411 + if (ops->change_mode) 412 + tzd->ops->change_mode = of_thermal_change_mode; 413 + 419 414 mutex_unlock(&tzd->lock); 420 415 421 416 return tzd; ··· 580 569 tzd->ops->get_temp = NULL; 581 570 tzd->ops->get_trend = NULL; 582 571 tzd->ops->set_emul_temp = NULL; 572 + tzd->ops->change_mode = NULL; 583 573 584 574 tz->ops = NULL; 585 575 tz->sensor_data = NULL;
+3
include/linux/thermal.h
··· 299 299 * temperature. 300 300 * @set_trip_temp: a pointer to a function that sets the trip temperature on 301 301 * hardware. 302 + * @change_mode: a pointer to a function that notifies the thermal zone 303 + * mode change. 302 304 */ 303 305 struct thermal_zone_of_device_ops { 304 306 int (*get_temp)(void *, int *); ··· 308 306 int (*set_trips)(void *, int, int); 309 307 int (*set_emul_temp)(void *, int); 310 308 int (*set_trip_temp)(void *, int, int); 309 + int (*change_mode) (void *, enum thermal_device_mode); 311 310 }; 312 311 313 312 /* Function declarations */