]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
thermal: of-thermal: allow setting trip_temp on hardware
authorWei Ni <wni@nvidia.com>
Tue, 29 Mar 2016 10:29:17 +0000 (18:29 +0800)
committerEduardo Valentin <edubezval@gmail.com>
Tue, 17 May 2016 14:28:28 +0000 (07:28 -0700)
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 <wni@nvidia.com>
Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
drivers/thermal/of-thermal.c
include/linux/thermal.h

index 82dd82afa55599a9e5befb3080f70693d91f36a5..b8e509c60848e4f94dc621185d334b59f8151c1a 100644 (file)
@@ -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;
 
index 1b8a5a7876ce67abbc0d6cac4004f816c31bf221..e45abe7db9a627dda034f7d4616fad2d3ae1f920 100644 (file)
@@ -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);
 };
 
 /**