diff options
-rw-r--r-- | drivers/thermal/thermal_core.c | 20 | ||||
-rw-r--r-- | include/linux/thermal.h | 1 |
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 | ||
372 | static 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 | */ | ||
382 | int 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, | |||
402 | skip_emul: | 414 | skip_emul: |
403 | #endif | 415 | #endif |
404 | mutex_unlock(&tz->lock); | 416 | mutex_unlock(&tz->lock); |
417 | exit: | ||
405 | return ret; | 418 | return ret; |
406 | } | 419 | } |
420 | EXPORT_SYMBOL_GPL(thermal_zone_get_temp); | ||
407 | 421 | ||
408 | static void update_temperature(struct thermal_zone_device *tz) | 422 | static 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 *); |
241 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); | 241 | void thermal_cooling_device_unregister(struct thermal_cooling_device *); |
242 | struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name); | 242 | struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name); |
243 | int thermal_zone_get_temp(struct thermal_zone_device *tz, unsigned long *temp); | ||
243 | 244 | ||
244 | int get_tz_trend(struct thermal_zone_device *, int); | 245 | int get_tz_trend(struct thermal_zone_device *, int); |
245 | struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, | 246 | struct thermal_instance *get_thermal_instance(struct thermal_zone_device *, |