diff options
| author | Jean Delvare <khali@linux-fr.org> | 2011-07-28 16:48:41 -0400 |
|---|---|---|
| committer | Len Brown <len.brown@intel.com> | 2011-08-02 14:51:41 -0400 |
| commit | 0d97d7a494d43be77f57e688369be0aae33d1ade (patch) | |
| tree | 18db258bdf750d254d1f72a9bfd3779485a2b6e5 /drivers/thermal | |
| parent | ab92402af04c151c26541eb28e1c26286a429db5 (diff) | |
thermal: split hwmon lookup to a separate function
We'll soon need to reuse it.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Rene Herman <rene.herman@gmail.com>
Acked-by: Guenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/thermal')
| -rw-r--r-- | drivers/thermal/thermal_sys.c | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/thermal/thermal_sys.c b/drivers/thermal/thermal_sys.c index 0b1c82ad6805..b6353d61fac5 100644 --- a/drivers/thermal/thermal_sys.c +++ b/drivers/thermal/thermal_sys.c | |||
| @@ -469,22 +469,35 @@ temp_crit_show(struct device *dev, struct device_attribute *attr, | |||
| 469 | } | 469 | } |
| 470 | 470 | ||
| 471 | 471 | ||
| 472 | static int | 472 | static struct thermal_hwmon_device * |
| 473 | thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) | 473 | thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz) |
| 474 | { | 474 | { |
| 475 | struct thermal_hwmon_device *hwmon; | 475 | struct thermal_hwmon_device *hwmon; |
| 476 | int new_hwmon_device = 1; | ||
| 477 | int result; | ||
| 478 | 476 | ||
| 479 | mutex_lock(&thermal_list_lock); | 477 | mutex_lock(&thermal_list_lock); |
| 480 | list_for_each_entry(hwmon, &thermal_hwmon_list, node) | 478 | list_for_each_entry(hwmon, &thermal_hwmon_list, node) |
| 481 | if (!strcmp(hwmon->type, tz->type)) { | 479 | if (!strcmp(hwmon->type, tz->type)) { |
| 482 | new_hwmon_device = 0; | ||
| 483 | mutex_unlock(&thermal_list_lock); | 480 | mutex_unlock(&thermal_list_lock); |
| 484 | goto register_sys_interface; | 481 | return hwmon; |
| 485 | } | 482 | } |
| 486 | mutex_unlock(&thermal_list_lock); | 483 | mutex_unlock(&thermal_list_lock); |
| 487 | 484 | ||
| 485 | return NULL; | ||
| 486 | } | ||
| 487 | |||
| 488 | static int | ||
| 489 | thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) | ||
| 490 | { | ||
| 491 | struct thermal_hwmon_device *hwmon; | ||
| 492 | int new_hwmon_device = 1; | ||
| 493 | int result; | ||
| 494 | |||
| 495 | hwmon = thermal_hwmon_lookup_by_type(tz); | ||
| 496 | if (hwmon) { | ||
| 497 | new_hwmon_device = 0; | ||
| 498 | goto register_sys_interface; | ||
| 499 | } | ||
| 500 | |||
| 488 | hwmon = kzalloc(sizeof(struct thermal_hwmon_device), GFP_KERNEL); | 501 | hwmon = kzalloc(sizeof(struct thermal_hwmon_device), GFP_KERNEL); |
| 489 | if (!hwmon) | 502 | if (!hwmon) |
| 490 | return -ENOMEM; | 503 | return -ENOMEM; |
