diff options
Diffstat (limited to 'drivers/hwmon/lm77.c')
-rw-r--r-- | drivers/hwmon/lm77.c | 33 |
1 files changed, 24 insertions, 9 deletions
diff --git a/drivers/hwmon/lm77.c b/drivers/hwmon/lm77.c index 459cc977380a..dd969f1e8415 100644 --- a/drivers/hwmon/lm77.c +++ b/drivers/hwmon/lm77.c | |||
@@ -212,6 +212,23 @@ static int lm77_attach_adapter(struct i2c_adapter *adapter) | |||
212 | return i2c_probe(adapter, &addr_data, lm77_detect); | 212 | return i2c_probe(adapter, &addr_data, lm77_detect); |
213 | } | 213 | } |
214 | 214 | ||
215 | static struct attribute *lm77_attributes[] = { | ||
216 | &dev_attr_temp1_input.attr, | ||
217 | &dev_attr_temp1_crit.attr, | ||
218 | &dev_attr_temp1_min.attr, | ||
219 | &dev_attr_temp1_max.attr, | ||
220 | &dev_attr_temp1_crit_hyst.attr, | ||
221 | &dev_attr_temp1_min_hyst.attr, | ||
222 | &dev_attr_temp1_max_hyst.attr, | ||
223 | &dev_attr_alarms.attr, | ||
224 | |||
225 | NULL | ||
226 | }; | ||
227 | |||
228 | static const struct attribute_group lm77_group = { | ||
229 | .attrs = lm77_attributes, | ||
230 | }; | ||
231 | |||
215 | /* This function is called by i2c_probe */ | 232 | /* This function is called by i2c_probe */ |
216 | static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | 233 | static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) |
217 | { | 234 | { |
@@ -317,22 +334,19 @@ static int lm77_detect(struct i2c_adapter *adapter, int address, int kind) | |||
317 | lm77_init_client(new_client); | 334 | lm77_init_client(new_client); |
318 | 335 | ||
319 | /* Register sysfs hooks */ | 336 | /* Register sysfs hooks */ |
337 | if ((err = sysfs_create_group(&new_client->dev.kobj, &lm77_group))) | ||
338 | goto exit_detach; | ||
339 | |||
320 | data->class_dev = hwmon_device_register(&new_client->dev); | 340 | data->class_dev = hwmon_device_register(&new_client->dev); |
321 | if (IS_ERR(data->class_dev)) { | 341 | if (IS_ERR(data->class_dev)) { |
322 | err = PTR_ERR(data->class_dev); | 342 | err = PTR_ERR(data->class_dev); |
323 | goto exit_detach; | 343 | goto exit_remove; |
324 | } | 344 | } |
325 | 345 | ||
326 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | ||
327 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | ||
328 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | ||
329 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | ||
330 | device_create_file(&new_client->dev, &dev_attr_temp1_crit_hyst); | ||
331 | device_create_file(&new_client->dev, &dev_attr_temp1_min_hyst); | ||
332 | device_create_file(&new_client->dev, &dev_attr_temp1_max_hyst); | ||
333 | device_create_file(&new_client->dev, &dev_attr_alarms); | ||
334 | return 0; | 346 | return 0; |
335 | 347 | ||
348 | exit_remove: | ||
349 | sysfs_remove_group(&new_client->dev.kobj, &lm77_group); | ||
336 | exit_detach: | 350 | exit_detach: |
337 | i2c_detach_client(new_client); | 351 | i2c_detach_client(new_client); |
338 | exit_free: | 352 | exit_free: |
@@ -345,6 +359,7 @@ static int lm77_detach_client(struct i2c_client *client) | |||
345 | { | 359 | { |
346 | struct lm77_data *data = i2c_get_clientdata(client); | 360 | struct lm77_data *data = i2c_get_clientdata(client); |
347 | hwmon_device_unregister(data->class_dev); | 361 | hwmon_device_unregister(data->class_dev); |
362 | sysfs_remove_group(&client->dev.kobj, &lm77_group); | ||
348 | i2c_detach_client(client); | 363 | i2c_detach_client(client); |
349 | kfree(data); | 364 | kfree(data); |
350 | return 0; | 365 | return 0; |