diff options
author | Zhang Rui <rui.zhang@intel.com> | 2013-04-24 09:43:00 -0400 |
---|---|---|
committer | Zhang Rui <rui.zhang@intel.com> | 2013-04-24 09:43:00 -0400 |
commit | 335553ce40f0e551383482ad6b0b0eba87f4f218 (patch) | |
tree | 02bcc35aed84699d3bbdb08961fa475100b296a8 /drivers/thermal | |
parent | 4f89038f177462dbd2fd911297fd004226176db7 (diff) | |
parent | 837b26bb2e4a83d224e725f07a1d9ca824bf905c (diff) |
Merge branch 'eduardo-1' of .git into next
Diffstat (limited to 'drivers/thermal')
-rw-r--r-- | drivers/thermal/thermal_core.c | 58 |
1 files changed, 55 insertions, 3 deletions
diff --git a/drivers/thermal/thermal_core.c b/drivers/thermal/thermal_core.c index 4cdc3e327222..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 | { |
@@ -1754,6 +1768,44 @@ void thermal_zone_device_unregister(struct thermal_zone_device *tz) | |||
1754 | } | 1768 | } |
1755 | EXPORT_SYMBOL(thermal_zone_device_unregister); | 1769 | EXPORT_SYMBOL(thermal_zone_device_unregister); |
1756 | 1770 | ||
1771 | /** | ||
1772 | * thermal_zone_get_zone_by_name() - search for a zone and returns its ref | ||
1773 | * @name: thermal zone name to fetch the temperature | ||
1774 | * | ||
1775 | * When only one zone is found with the passed name, returns a reference to it. | ||
1776 | * | ||
1777 | * Return: On success returns a reference to an unique thermal zone with | ||
1778 | * matching name equals to @name, an ERR_PTR otherwise (-EINVAL for invalid | ||
1779 | * paramenters, -ENODEV for not found and -EEXIST for multiple matches). | ||
1780 | */ | ||
1781 | struct thermal_zone_device *thermal_zone_get_zone_by_name(const char *name) | ||
1782 | { | ||
1783 | struct thermal_zone_device *pos = NULL, *ref = ERR_PTR(-EINVAL); | ||
1784 | unsigned int found = 0; | ||
1785 | |||
1786 | if (!name) | ||
1787 | goto exit; | ||
1788 | |||
1789 | mutex_lock(&thermal_list_lock); | ||
1790 | list_for_each_entry(pos, &thermal_tz_list, node) | ||
1791 | if (!strnicmp(name, pos->type, THERMAL_NAME_LENGTH)) { | ||
1792 | found++; | ||
1793 | ref = pos; | ||
1794 | } | ||
1795 | mutex_unlock(&thermal_list_lock); | ||
1796 | |||
1797 | /* nothing has been found, thus an error code for it */ | ||
1798 | if (found == 0) | ||
1799 | ref = ERR_PTR(-ENODEV); | ||
1800 | else if (found > 1) | ||
1801 | /* Success only when an unique zone is found */ | ||
1802 | ref = ERR_PTR(-EEXIST); | ||
1803 | |||
1804 | exit: | ||
1805 | return ref; | ||
1806 | } | ||
1807 | EXPORT_SYMBOL_GPL(thermal_zone_get_zone_by_name); | ||
1808 | |||
1757 | #ifdef CONFIG_NET | 1809 | #ifdef CONFIG_NET |
1758 | static struct genl_family thermal_event_genl_family = { | 1810 | static struct genl_family thermal_event_genl_family = { |
1759 | .id = GENL_ID_GENERATE, | 1811 | .id = GENL_ID_GENERATE, |