Skip to content

Commit

Permalink
thermal: of-thermal: allow setting trip_temp on hardware
Browse files Browse the repository at this point in the history
In current of-thermal, the .set_trip_temp only support to
set trip_temp for SW. But some sensors support to set
trip_temp on hardware, so that can trigger interrupt,
shutdown or any other events.
This patch adds .set_trip_temp() callback in
thermal_zone_of_device_ops{}, so that the sensor device can
use it to set trip_temp on hardware.

Signed-off-by: Wei Ni <[email protected]>
Signed-off-by: Eduardo Valentin <[email protected]>
  • Loading branch information
wni-WeiNi authored and Eduardo Valentin committed May 17, 2016
1 parent d753b22 commit c350952
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions drivers/thermal/of-thermal.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,14 @@ static int of_thermal_set_trip_temp(struct thermal_zone_device *tz, int trip,
if (trip >= data->ntrips || trip < 0)
return -EDOM;

if (data->ops->set_trip_temp) {
int ret;

ret = data->ops->set_trip_temp(data->sensor_data, trip, temp);
if (ret)
return ret;
}

/* thermal framework should take care of data->mask & (1 << trip) */
data->trips[trip].temperature = temp;

Expand Down
1 change: 1 addition & 0 deletions include/linux/thermal.h
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ struct thermal_zone_of_device_ops {
int (*get_temp)(void *, int *);
int (*get_trend)(void *, long *);
int (*set_emul_temp)(void *, int);
int (*set_trip_temp)(void *, int, int);
};

/**
Expand Down

0 comments on commit c350952

Please sign in to comment.