aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/thermal/thermal_hwmon.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/thermal/thermal_hwmon.c')
-rw-r--r--drivers/thermal/thermal_hwmon.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/drivers/thermal/thermal_hwmon.c b/drivers/thermal/thermal_hwmon.c
index c4a508a124dc..541af5946203 100644
--- a/drivers/thermal/thermal_hwmon.c
+++ b/drivers/thermal/thermal_hwmon.c
@@ -59,6 +59,14 @@ static LIST_HEAD(thermal_hwmon_list);
59static DEFINE_MUTEX(thermal_hwmon_list_lock); 59static DEFINE_MUTEX(thermal_hwmon_list_lock);
60 60
61static ssize_t 61static ssize_t
62name_show(struct device *dev, struct device_attribute *attr, char *buf)
63{
64 struct thermal_hwmon_device *hwmon = dev_get_drvdata(dev);
65 return sprintf(buf, "%s\n", hwmon->type);
66}
67static DEVICE_ATTR_RO(name);
68
69static ssize_t
62temp_input_show(struct device *dev, struct device_attribute *attr, char *buf) 70temp_input_show(struct device *dev, struct device_attribute *attr, char *buf)
63{ 71{
64 int temperature; 72 int temperature;
@@ -157,12 +165,15 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
157 165
158 INIT_LIST_HEAD(&hwmon->tz_list); 166 INIT_LIST_HEAD(&hwmon->tz_list);
159 strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH); 167 strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
160 hwmon->device = hwmon_device_register_with_info(NULL, hwmon->type, 168 hwmon->device = hwmon_device_register(NULL);
161 hwmon, NULL, NULL);
162 if (IS_ERR(hwmon->device)) { 169 if (IS_ERR(hwmon->device)) {
163 result = PTR_ERR(hwmon->device); 170 result = PTR_ERR(hwmon->device);
164 goto free_mem; 171 goto free_mem;
165 } 172 }
173 dev_set_drvdata(hwmon->device, hwmon);
174 result = device_create_file(hwmon->device, &dev_attr_name);
175 if (result)
176 goto free_mem;
166 177
167 register_sys_interface: 178 register_sys_interface:
168 temp = kzalloc(sizeof(*temp), GFP_KERNEL); 179 temp = kzalloc(sizeof(*temp), GFP_KERNEL);
@@ -211,8 +222,10 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
211 free_temp_mem: 222 free_temp_mem:
212 kfree(temp); 223 kfree(temp);
213 unregister_name: 224 unregister_name:
214 if (new_hwmon_device) 225 if (new_hwmon_device) {
226 device_remove_file(hwmon->device, &dev_attr_name);
215 hwmon_device_unregister(hwmon->device); 227 hwmon_device_unregister(hwmon->device);
228 }
216 free_mem: 229 free_mem:
217 if (new_hwmon_device) 230 if (new_hwmon_device)
218 kfree(hwmon); 231 kfree(hwmon);
@@ -254,6 +267,7 @@ void thermal_remove_hwmon_sysfs(struct thermal_zone_device *tz)
254 list_del(&hwmon->node); 267 list_del(&hwmon->node);
255 mutex_unlock(&thermal_hwmon_list_lock); 268 mutex_unlock(&thermal_hwmon_list_lock);
256 269
270 device_remove_file(hwmon->device, &dev_attr_name);
257 hwmon_device_unregister(hwmon->device); 271 hwmon_device_unregister(hwmon->device);
258 kfree(hwmon); 272 kfree(hwmon);
259} 273}