Skip to content

Commit bf70c57

Browse files
quic-manafmdlezcano
authored andcommitted
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>
1 parent 106e012 commit bf70c57

2 files changed

Lines changed: 15 additions & 0 deletions

File tree

drivers/thermal/thermal_of.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,14 @@ static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
203203
return data->ops->get_trend(data->sensor_data, trip, trend);
204204
}
205205

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+
206214
static int of_thermal_bind(struct thermal_zone_device *thermal,
207215
struct thermal_cooling_device *cdev)
208216
{
@@ -408,6 +416,9 @@ thermal_zone_of_add_sensor(struct device_node *zone,
408416
if (ops->set_emul_temp)
409417
tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
410418

419+
if (ops->change_mode)
420+
tzd->ops->change_mode = of_thermal_change_mode;
421+
411422
mutex_unlock(&tzd->lock);
412423

413424
return tzd;
@@ -569,6 +580,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
569580
tzd->ops->get_temp = NULL;
570581
tzd->ops->get_trend = NULL;
571582
tzd->ops->set_emul_temp = NULL;
583+
tzd->ops->change_mode = NULL;
572584

573585
tz->ops = NULL;
574586
tz->sensor_data = NULL;

include/linux/thermal.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,13 +299,16 @@ struct thermal_zone_params {
299299
* temperature.
300300
* @set_trip_temp: a pointer to a function that sets the trip temperature on
301301
* hardware.
302+
* @change_mode: a pointer to a function that notifies the thermal zone
303+
* mode change.
302304
*/
303305
struct thermal_zone_of_device_ops {
304306
int (*get_temp)(void *, int *);
305307
int (*get_trend)(void *, int, enum thermal_trend *);
306308
int (*set_trips)(void *, int, int);
307309
int (*set_emul_temp)(void *, int);
308310
int (*set_trip_temp)(void *, int, int);
311+
int (*change_mode) (void *, enum thermal_device_mode);
309312
};
310313

311314
/* Function declarations */

0 commit comments

Comments
 (0)