From 8e44c4b7cb1beba4381b9f576ab420b7120ffd4e Mon Sep 17 00:00:00 2001 From: Manaf Meethalavalappu Pallikunhi Date: Tue, 7 Jun 2022 02:46:26 +0530 Subject: [PATCH] FROMLIST: drivers/thermal/thermal_of: Add critical/hot ops support for thermal_of sensor 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 Bug: 226570053 Change-Id: I5e3d5a4b360d134ae70e9fcdb88ca2b4de0b79b2 Link: https://lore.kernel.org/all/20220601131400.24627-2-quic_manafm@quicinc.com/ Signed-off-by: Manaf Meethalavalappu Pallikunhi --- drivers/thermal/thermal_of.c | 21 +++++++++++++++++++++ include/linux/thermal.h | 6 ++++++ 2 files changed, 27 insertions(+) diff --git a/drivers/thermal/thermal_of.c b/drivers/thermal/thermal_of.c index da484800906f..ca73c9767891 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 f195baf4ea89..84fd13ecea8d 100644 --- a/include/linux/thermal.h +++ b/include/linux/thermal.h @@ -316,6 +316,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 *); @@ -324,6 +328,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); ANDROID_KABI_RESERVE(1); };