diff options
author | Eduardo Valentin <eduardo.valentin@ti.com> | 2013-04-05 08:32:29 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2013-04-14 21:39:02 -0400 |
commit | 837b26bb2e4a83d224e725f07a1d9ca824bf905c (patch) | |
tree | 7dc6a3c904b5a434f0c1fb48daa99e9dbbb704a0 /drivers/thermal | |
parent | 63c4d919cf66b1b3ffa7861bddb50a697914af5b (diff) |
thermal: expose thermal_zone_get_temp API
This patch exports the thermal_zone_get_temp API so that driver
writers can fetch temperature of thermal zones managed by other
drivers.
Acked-by: Durgadoss R <durgadoss.r@intel.com>
Signed-off-by: Eduardo Valentin <eduardo.valentin@ti.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/thermal_core.c | 20 |
1 files changed, 17 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 | { |