aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/thermal/thermal_core.c20
-rw-r--r--include/linux/thermal.h1
2 files changed, 18 insertions, 3 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c
index 5045473485cf..c0779adb2459 100644
--- a/drivers/thermal/thermal_core.c
+++ b/drivers/thermal/thermal_core.c
@@ -369,16 +369,28 @@ static void handle_thermal_trip(struct thermal_zone_device *tz, int trip)
369 monitor_thermal_zone(tz); 369 monitor_thermal_zone(tz);
370} 370}
371 371
372static int thermal_zone_get_temp(struct thermal_zone_device *tz, 372/**
373 unsigned long *temp) 373 * thermal_zone_get_temp() - returns its the temperature of thermal zone
374 * @tz: a valid pointer to a struct thermal_zone_device
375 * @temp: a valid pointer to where to store the resulting temperature.
376 *
377 * When a valid thermal zone reference is passed, it will fetch its
378 * temperature and fill @temp.
379 *
380 * Return: On success returns 0, an error code otherwise
381 */
382int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp)
374{ 383{
375 int ret = 0; 384 int ret = -EINVAL;
376#ifdef CONFIG_THERMAL_EMULATION 385#ifdef CONFIG_THERMAL_EMULATION
377 int count; 386 int count;
378 unsigned long crit_temp = -1UL; 387 unsigned long crit_temp = -1UL;
379 enum thermal_trip_type type; 388 enum thermal_trip_type type;
380#endif 389#endif
381 390
391 if (IS_ERR_OR_NULL(tz))
392 goto exit;
393
382 mutex_lock(&tz->lock); 394 mutex_lock(&tz->lock);
383 395
384 ret = tz->ops->get_temp(tz, temp); 396 ret = tz->ops->get_temp(tz, temp);
@@ -402,8 +414,10 @@ static int thermal_zone_get_temp(struct thermal_zone_device *tz,
402skip_emul: 414skip_emul:
403#endif 415#endif
404 mutex_unlock(&tz->lock); 416 mutex_unlock(&tz->lock);
417exit:
405 return ret; 418 return ret;
406} 419}
420EXPORT_SYMBOL_GPL(thermal_zone_get_temp);
407 421
408static void update_temperature(struct thermal_zone_device *tz) 422static void update_temperature(struct thermal_zone_device *tz)
409{ 423{
diff --git a/include/linux/thermal.h b/include/linux/thermal.h
index 9af2f3a99658..ec2b886f9d96 100644
--- a/include/linux/thermal.h
+++ b/include/linux/thermal.h
@@ -240,6 +240,7 @@ struct thermal_cooling_device *thermal_cooling_device_register(char *, void *,
240 const struct thermal_cooling_device_ops *); 240 const struct thermal_cooling_device_ops *);
241void thermal_cooling_device_unregister(struct thermal_cooling_device *); 241void thermal_cooling_device_unregister(struct thermal_cooling_device *);
242struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name); 242struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name);
243int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp);
243 244
244int get_tz_trend(struct thermal_zone_device *, int); 245int get_tz_trend(struct thermal_zone_device *, int);
245struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, 246struct thermal_instance *get_thermal_instance(struct thermal_zone_device *,