aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Majewski <l.majewski@samsung.com>2014-12-08 12:04:21 -0500
committerEduardo Valentin <edubezval@gmail.com>2014-12-08 20:10:00 -0500
commit184a4bf623fa587067851d25435fcb2f41de445b (patch)
tree98023bf8abd50b6672f3e4b0f34e9c41c7944456
parentce8be7785922de0ef497b20384425ed04f674f9d (diff)
thermal: of: Extend current of-thermal.c code to allow setting emulated temp
Before this change it was only possible to set get_temp() and get_trend() methods to be used in the common code handling passing parameters via device tree to "cpu-thermal" CPU thermal zone device. Now it is possible to also set emulated value of temperature for debug purposes. Signed-off-by: Lukasz Majewski <l.majewski@samsung.com> Acked-by: Eduardo Valentin <edubezval@gmail.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
-rw-r--r--drivers/thermal/of-thermal.c24
-rw-r--r--include/linux/thermal.h3
2 files changed, 27 insertions, 0 deletions
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c
index e062bf59ab6c..e145b66df444 100644
--- a/drivers/thermal/of-thermal.c
+++ b/drivers/thermal/of-thermal.c
@@ -161,6 +161,28 @@ of_thermal_get_trip_points(struct thermal_zone_device *tz)
161} 161}
162EXPORT_SYMBOL_GPL(of_thermal_get_trip_points); 162EXPORT_SYMBOL_GPL(of_thermal_get_trip_points);
163 163
164/**
165 * of_thermal_set_emul_temp - function to set emulated temperature
166 *
167 * @tz: pointer to a thermal zone
168 * @temp: temperature to set
169 *
170 * This function gives the ability to set emulated value of temperature,
171 * which is handy for debugging
172 *
173 * Return: zero on success, error code otherwise
174 */
175static int of_thermal_set_emul_temp(struct thermal_zone_device *tz,
176 unsigned long temp)
177{
178 struct __thermal_zone *data = tz->devdata;
179
180 if (!data->ops || !data->ops->set_emul_temp)
181 return -EINVAL;
182
183 return data->ops->set_emul_temp(data->sensor_data, temp);
184}
185
164static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip, 186static int of_thermal_get_trend(struct thermal_zone_device *tz, int trip,
165 enum thermal_trend *trend) 187 enum thermal_trend *trend)
166{ 188{
@@ -392,6 +414,7 @@ thermal_zone_of_add_sensor(struct device_node *zone,
392 414
393 tzd->ops->get_temp = of_thermal_get_temp; 415 tzd->ops->get_temp = of_thermal_get_temp;
394 tzd->ops->get_trend = of_thermal_get_trend; 416 tzd->ops->get_trend = of_thermal_get_trend;
417 tzd->ops->set_emul_temp = of_thermal_set_emul_temp;
395 mutex_unlock(&tzd->lock); 418 mutex_unlock(&tzd->lock);
396 419
397 return tzd; 420 return tzd;
@@ -520,6 +543,7 @@ void thermal_zone_of_sensor_unregister(struct device *dev,
520 mutex_lock(&tzd->lock); 543 mutex_lock(&tzd->lock);
521 tzd->ops->get_temp = NULL; 544 tzd->ops->get_temp = NULL;
522 tzd->ops->get_trend = NULL; 545 tzd->ops->get_trend = NULL;
546 tzd->ops->set_emul_temp = NULL;
523 547
524 tz->ops = NULL; 548 tz->ops = NULL;
525 tz->sensor_data = NULL; 549 tz->sensor_data = NULL;
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index b8d91efa854e..99be7fc79c3b 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -297,10 +297,13 @@ struct thermal_genl_event {
297 * 297 *
298 * Optional: 298 * Optional:
299 * @get_trend: a pointer to a function that reads the sensor temperature trend. 299 * @get_trend: a pointer to a function that reads the sensor temperature trend.
300 * @set_emul_temp: a pointer to a function that sets sensor emulated
301 * temperature.
300 */ 302 */
301struct thermal_zone_of_device_ops { 303struct thermal_zone_of_device_ops {
302 int (*get_temp)(void *, long *); 304 int (*get_temp)(void *, long *);
303 int (*get_trend)(void *, long *); 305 int (*get_trend)(void *, long *);
306 int (*set_emul_temp)(void *, unsigned long);
304}; 307};
305 308
306/** 309/**