0021-thermal-of-implement-.set_trips-for-device-tree-ther.patch 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. From 525f68bb9d9f6334dbcd2b5ec99f9d797ff53618 Mon Sep 17 00:00:00 2001
  2. From: Sascha Hauer <[email protected]>
  3. Date: Wed, 13 May 2015 10:52:40 +0200
  4. Subject: [PATCH 21/76] thermal: of: implement .set_trips for device tree
  5. thermal zones
  6. Signed-off-by: Sascha Hauer <[email protected]>
  7. ---
  8. drivers/thermal/of-thermal.c | 12 ++++++++++++
  9. include/linux/thermal.h | 3 +++
  10. 2 files changed, 15 insertions(+)
  11. --- a/drivers/thermal/of-thermal.c
  12. +++ b/drivers/thermal/of-thermal.c
  13. @@ -97,6 +97,17 @@ static int of_thermal_get_temp(struct th
  14. return data->ops->get_temp(data->sensor_data, temp);
  15. }
  16. +static int of_thermal_set_trips(struct thermal_zone_device *tz,
  17. + int low, int high)
  18. +{
  19. + struct __thermal_zone *data = tz->devdata;
  20. +
  21. + if (!data->ops || !data->ops->set_trips)
  22. + return -ENOSYS;
  23. +
  24. + return data->ops->set_trips(data->sensor_data, low, high);
  25. +}
  26. +
  27. /**
  28. * of_thermal_get_ntrips - function to export number of available trip
  29. * points.
  30. @@ -367,6 +378,7 @@ static int of_thermal_get_crit_temp(stru
  31. static const struct thermal_zone_device_ops of_thermal_ops = {
  32. .get_temp = of_thermal_get_temp,
  33. + .set_trips = of_thermal_set_trips,
  34. .get_trend = of_thermal_get_trend,
  35. .set_emul_temp = of_thermal_set_emul_temp,
  36. --- a/include/linux/thermal.h
  37. +++ b/include/linux/thermal.h
  38. @@ -272,12 +272,15 @@ struct thermal_genl_event {
  39. *
  40. * Optional:
  41. * @get_trend: a pointer to a function that reads the sensor temperature trend.
  42. + * @set_trips: a pointer to a function that sets a temperature window which shall
  43. + * trigger an interrupt when it is left.
  44. * @set_emul_temp: a pointer to a function that sets sensor emulated
  45. * temperature.
  46. */
  47. struct thermal_zone_of_device_ops {
  48. int (*get_temp)(void *, int *);
  49. int (*get_trend)(void *, int, enum thermal_trend *);
  50. + int (*set_trips)(void *, int, int);
  51. int (*set_emul_temp)(void *, int);
  52. };