提交 0d97d7a4 编写于 作者: J Jean Delvare 提交者: Len Brown

thermal: split hwmon lookup to a separate function

We'll soon need to reuse it.
Signed-off-by: NJean Delvare <khali@linux-fr.org>
Cc: Rene Herman <rene.herman@gmail.com>
Acked-by: NGuenter Roeck <guenter.roeck@ericsson.com>
Signed-off-by: NAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: NLen Brown <len.brown@intel.com>
上级 ab92402a
...@@ -469,22 +469,35 @@ temp_crit_show(struct device *dev, struct device_attribute *attr, ...@@ -469,22 +469,35 @@ temp_crit_show(struct device *dev, struct device_attribute *attr,
} }
static int static struct thermal_hwmon_device *
thermal_add_hwmon_sysfs(struct thermal_zone_device *tz) thermal_hwmon_lookup_by_type(const struct thermal_zone_device *tz)
{ {
struct thermal_hwmon_device *hwmon; struct thermal_hwmon_device *hwmon;
int new_hwmon_device = 1;
int result;
mutex_lock(&thermal_list_lock); mutex_lock(&thermal_list_lock);
list_for_each_entry(hwmon, &thermal_hwmon_list, node) list_for_each_entry(hwmon, &thermal_hwmon_list, node)
if (!strcmp(hwmon->type, tz->type)) { if (!strcmp(hwmon->type, tz->type)) {
new_hwmon_device = 0;
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
goto register_sys_interface; return hwmon;
} }
mutex_unlock(&thermal_list_lock); mutex_unlock(&thermal_list_lock);
return NULL;
}
static int
thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
{
struct thermal_hwmon_device *hwmon;
int new_hwmon_device = 1;
int result;
hwmon = thermal_hwmon_lookup_by_type(tz);
if (hwmon) {
new_hwmon_device = 0;
goto register_sys_interface;
}
hwmon = kzalloc(sizeof(struct thermal_hwmon_device), GFP_KERNEL); hwmon = kzalloc(sizeof(struct thermal_hwmon_device), GFP_KERNEL);
if (!hwmon) if (!hwmon)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册