diff options
Diffstat (limited to 'drivers/hwmon/adm1021.c')
-rw-r--r-- | drivers/hwmon/adm1021.c | 31 |
1 files changed, 22 insertions, 9 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index 2b6e74dd4a82..c466329b2ef4 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -190,6 +190,21 @@ static int adm1021_attach_adapter(struct i2c_adapter *adapter) | |||
190 | return i2c_probe(adapter, &addr_data, adm1021_detect); | 190 | return i2c_probe(adapter, &addr_data, adm1021_detect); |
191 | } | 191 | } |
192 | 192 | ||
193 | static struct attribute *adm1021_attributes[] = { | ||
194 | &dev_attr_temp1_max.attr, | ||
195 | &dev_attr_temp1_min.attr, | ||
196 | &dev_attr_temp1_input.attr, | ||
197 | &dev_attr_temp2_max.attr, | ||
198 | &dev_attr_temp2_min.attr, | ||
199 | &dev_attr_temp2_input.attr, | ||
200 | &dev_attr_alarms.attr, | ||
201 | NULL | ||
202 | }; | ||
203 | |||
204 | static const struct attribute_group adm1021_group = { | ||
205 | .attrs = adm1021_attributes, | ||
206 | }; | ||
207 | |||
193 | static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | 208 | static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) |
194 | { | 209 | { |
195 | int i; | 210 | int i; |
@@ -287,22 +302,19 @@ static int adm1021_detect(struct i2c_adapter *adapter, int address, int kind) | |||
287 | adm1021_init_client(new_client); | 302 | adm1021_init_client(new_client); |
288 | 303 | ||
289 | /* Register sysfs hooks */ | 304 | /* Register sysfs hooks */ |
305 | if ((err = sysfs_create_group(&new_client->dev.kobj, &adm1021_group))) | ||
306 | goto error2; | ||
307 | |||
290 | data->class_dev = hwmon_device_register(&new_client->dev); | 308 | data->class_dev = hwmon_device_register(&new_client->dev); |
291 | if (IS_ERR(data->class_dev)) { | 309 | if (IS_ERR(data->class_dev)) { |
292 | err = PTR_ERR(data->class_dev); | 310 | err = PTR_ERR(data->class_dev); |
293 | goto error2; | 311 | goto error3; |
294 | } | 312 | } |
295 | 313 | ||
296 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | ||
297 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | ||
298 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | ||
299 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | ||
300 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | ||
301 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | ||
302 | device_create_file(&new_client->dev, &dev_attr_alarms); | ||
303 | |||
304 | return 0; | 314 | return 0; |
305 | 315 | ||
316 | error3: | ||
317 | sysfs_remove_group(&new_client->dev.kobj, &adm1021_group); | ||
306 | error2: | 318 | error2: |
307 | i2c_detach_client(new_client); | 319 | i2c_detach_client(new_client); |
308 | error1: | 320 | error1: |
@@ -326,6 +338,7 @@ static int adm1021_detach_client(struct i2c_client *client) | |||
326 | int err; | 338 | int err; |
327 | 339 | ||
328 | hwmon_device_unregister(data->class_dev); | 340 | hwmon_device_unregister(data->class_dev); |
341 | sysfs_remove_group(&client->dev.kobj, &adm1021_group); | ||
329 | 342 | ||
330 | if ((err = i2c_detach_client(client))) | 343 | if ((err = i2c_detach_client(client))) |
331 | return err; | 344 | return err; |