From: Wei Ni Date: Tue, 29 Mar 2016 10:29:17 +0000 (+0800) Subject: UPSTREAM: thermal: of-thermal: allow setting trip_temp on hardware X-Git-Tag: firefly_0821_release~2921 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=96608532b3ae8e5f9eff99f9a729ad198272f84a;p=firefly-linux-kernel-4.4.55.git UPSTREAM: thermal: of-thermal: allow setting trip_temp on hardware 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. Change-Id: I879ea144a9ac21a5032dd885118887b4942c96cf Signed-off-by: Wei Ni Signed-off-by: Eduardo Valentin Signed-off-by: Caesar Wang (cherry picked from git.kernel.org next/linux-next.git master commit 60f9ce3ada53498409d51da06502392884933f89) --- diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index 5a515f8677ec..57828841b6e6 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c @@ -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; diff --git a/include/linux/thermal.h b/include/linux/thermal.h index 9c481991fdc7..fcaab873b94f 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -338,6 +338,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); }; /**