diff mbox series

[1/1] drivers/thermal/thermal_of: Add critical/hot ops support for thermal_of sensor

Message ID 20220601131400.24627-2-quic_manafm@quicinc.com
State New
Headers show
Series drivers/thermal/thermal_of: Add critical/hot ops support for thermal_of sensor | expand

Commit Message

Manaf Meethalavalappu Pallikunhi June 1, 2022, 1:14 p.m. UTC
The sensor driver which register through thermal_of interface doesn't
have an option to get thermal zone critical, hot trip violation
notification from thermal core.

Add support for these ops in thermal_of interface so that sensor
driver can use these ops.

Signed-off-by: Manaf Meethalavalappu Pallikunhi <quic_manafm@quicinc.com>
---
 drivers/thermal/thermal_of.c | 21 +++++++++++++++++++++
 include/linux/thermal.h      |  6 ++++++
 2 files changed, 27 insertions(+)
diff mbox series

Patch

diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c
index b65d435cb92f..65e1848cb1dd 100644
--- a/drivers/thermal/thermal_of.c
+++ b/drivers/thermal/thermal_of.c
@@ -211,6 +211,20 @@  static int of_thermal_change_mode(struct thermal_zone_device *tz,
 	return data->ops->change_mode(data->sensor_data, mode);
 }
 
+static void of_thermal_hot_notify(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	data->ops->hot(data->sensor_data);
+}
+
+static void of_thermal_critical_notify(struct thermal_zone_device *tz)
+{
+	struct __thermal_zone *data = tz->devdata;
+
+	data->ops->critical(data->sensor_data);
+}
+
 static int of_thermal_bind(struct thermal_zone_device *thermal,
 			   struct thermal_cooling_device *cdev)
 {
@@ -419,6 +433,11 @@  thermal_zone_of_add_sensor(struct device_node *zone,
 	if (ops->change_mode)
 		tzd->ops->change_mode = of_thermal_change_mode;
 
+	if (ops->hot)
+		tzd->ops->hot = of_thermal_hot_notify;
+
+	if (ops->critical)
+		tzd->ops->critical = of_thermal_critical_notify;
 	mutex_unlock(&tzd->lock);
 
 	return tzd;
@@ -581,6 +600,8 @@  void thermal_zone_of_sensor_unregister(struct device *dev,
 	tzd->ops->get_trend = NULL;
 	tzd->ops->set_emul_temp = NULL;
 	tzd->ops->change_mode = NULL;
+	tzd->ops->hot = NULL;
+	tzd->ops->critical = NULL;
 
 	tz->ops = NULL;
 	tz->sensor_data = NULL;
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 365733b428d8..920f7e5c80bb 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -301,6 +301,10 @@  struct thermal_zone_params {
  *		   hardware.
  * @change_mode: a pointer to a function that notifies the thermal zone
  *		   mode change.
+ * @hot:	 a pointer to a function that notifies the thermal zone
+ *		   hot trip violation.
+ * @critical: a pointer to a function that notifies the thermal zone
+ *		   critical trip violation.
  */
 struct thermal_zone_of_device_ops {
 	int (*get_temp)(void *, int *);
@@ -309,6 +313,8 @@  struct thermal_zone_of_device_ops {
 	int (*set_emul_temp)(void *, int);
 	int (*set_trip_temp)(void *, int, int);
 	int (*change_mode) (void *, enum thermal_device_mode);
+	void (*hot)(void *sensor_data);
+	void (*critical)(void *sensor_data);
 };
 
 /* Function declarations */