diff options
author | Jean Delvare <khali@linux-fr.org> | 2006-09-24 15:16:40 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-28 18:31:18 -0400 |
commit | 0e39e01c908fdc498fff0d788fd7b955ab75ebb6 (patch) | |
tree | 2e117466ec9a60f3dac6d678e95af97454aa6c8c /drivers/hwmon/lm90.c | |
parent | 681c6f7a6702f208d48b501c8829dbc03a2ca238 (diff) |
hwmon: Fix unchecked return status, batch 4
hwmon: Fix unchecked return status, batch 4
Fix up some hwmon drivers so that they no longer ignore return status
from device_create_file().
Note: f71805f actually checked the status from device_create_file
already. However it did not remove the files on device destruction.
It was also an opportunity to use sysfs_create/remove_group instead
of hand-made loops. This makes the changes much more important but
I think the result is worth it.
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/lm90.c')
-rw-r--r-- | drivers/hwmon/lm90.c | 83 |
1 files changed, 42 insertions, 41 deletions
diff --git a/drivers/hwmon/lm90.c b/drivers/hwmon/lm90.c index 77f8e3f7fd49..6882ce75feee 100644 --- a/drivers/hwmon/lm90.c +++ b/drivers/hwmon/lm90.c | |||
@@ -79,6 +79,7 @@ | |||
79 | #include <linux/hwmon.h> | 79 | #include <linux/hwmon.h> |
80 | #include <linux/err.h> | 80 | #include <linux/err.h> |
81 | #include <linux/mutex.h> | 81 | #include <linux/mutex.h> |
82 | #include <linux/sysfs.h> | ||
82 | 83 | ||
83 | /* | 84 | /* |
84 | * Addresses to scan | 85 | * Addresses to scan |
@@ -366,6 +367,33 @@ static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); | |||
366 | /* Raw alarm file for compatibility */ | 367 | /* Raw alarm file for compatibility */ |
367 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); | 368 | static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); |
368 | 369 | ||
370 | static struct attribute *lm90_attributes[] = { | ||
371 | &sensor_dev_attr_temp1_input.dev_attr.attr, | ||
372 | &sensor_dev_attr_temp2_input.dev_attr.attr, | ||
373 | &sensor_dev_attr_temp1_min.dev_attr.attr, | ||
374 | &sensor_dev_attr_temp2_min.dev_attr.attr, | ||
375 | &sensor_dev_attr_temp1_max.dev_attr.attr, | ||
376 | &sensor_dev_attr_temp2_max.dev_attr.attr, | ||
377 | &sensor_dev_attr_temp1_crit.dev_attr.attr, | ||
378 | &sensor_dev_attr_temp2_crit.dev_attr.attr, | ||
379 | &sensor_dev_attr_temp1_crit_hyst.dev_attr.attr, | ||
380 | &sensor_dev_attr_temp2_crit_hyst.dev_attr.attr, | ||
381 | |||
382 | &sensor_dev_attr_temp1_crit_alarm.dev_attr.attr, | ||
383 | &sensor_dev_attr_temp2_crit_alarm.dev_attr.attr, | ||
384 | &sensor_dev_attr_temp2_input_fault.dev_attr.attr, | ||
385 | &sensor_dev_attr_temp2_min_alarm.dev_attr.attr, | ||
386 | &sensor_dev_attr_temp2_max_alarm.dev_attr.attr, | ||
387 | &sensor_dev_attr_temp1_min_alarm.dev_attr.attr, | ||
388 | &sensor_dev_attr_temp1_max_alarm.dev_attr.attr, | ||
389 | &dev_attr_alarms.attr, | ||
390 | NULL | ||
391 | }; | ||
392 | |||
393 | static const struct attribute_group lm90_group = { | ||
394 | .attrs = lm90_attributes, | ||
395 | }; | ||
396 | |||
369 | /* pec used for ADM1032 only */ | 397 | /* pec used for ADM1032 only */ |
370 | static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, | 398 | static ssize_t show_pec(struct device *dev, struct device_attribute *dummy, |
371 | char *buf) | 399 | char *buf) |
@@ -589,54 +617,25 @@ static int lm90_detect(struct i2c_adapter *adapter, int address, int kind) | |||
589 | lm90_init_client(new_client); | 617 | lm90_init_client(new_client); |
590 | 618 | ||
591 | /* Register sysfs hooks */ | 619 | /* Register sysfs hooks */ |
620 | if ((err = sysfs_create_group(&new_client->dev.kobj, &lm90_group))) | ||
621 | goto exit_detach; | ||
622 | if (new_client->flags & I2C_CLIENT_PEC) { | ||
623 | if ((err = device_create_file(&new_client->dev, | ||
624 | &dev_attr_pec))) | ||
625 | goto exit_remove_files; | ||
626 | } | ||
627 | |||
592 | data->class_dev = hwmon_device_register(&new_client->dev); | 628 | data->class_dev = hwmon_device_register(&new_client->dev); |
593 | if (IS_ERR(data->class_dev)) { | 629 | if (IS_ERR(data->class_dev)) { |
594 | err = PTR_ERR(data->class_dev); | 630 | err = PTR_ERR(data->class_dev); |
595 | goto exit_detach; | 631 | goto exit_remove_files; |
596 | } | 632 | } |
597 | 633 | ||
598 | device_create_file(&new_client->dev, | ||
599 | &sensor_dev_attr_temp1_input.dev_attr); | ||
600 | device_create_file(&new_client->dev, | ||
601 | &sensor_dev_attr_temp2_input.dev_attr); | ||
602 | device_create_file(&new_client->dev, | ||
603 | &sensor_dev_attr_temp1_min.dev_attr); | ||
604 | device_create_file(&new_client->dev, | ||
605 | &sensor_dev_attr_temp2_min.dev_attr); | ||
606 | device_create_file(&new_client->dev, | ||
607 | &sensor_dev_attr_temp1_max.dev_attr); | ||
608 | device_create_file(&new_client->dev, | ||
609 | &sensor_dev_attr_temp2_max.dev_attr); | ||
610 | device_create_file(&new_client->dev, | ||
611 | &sensor_dev_attr_temp1_crit.dev_attr); | ||
612 | device_create_file(&new_client->dev, | ||
613 | &sensor_dev_attr_temp2_crit.dev_attr); | ||
614 | device_create_file(&new_client->dev, | ||
615 | &sensor_dev_attr_temp1_crit_hyst.dev_attr); | ||
616 | device_create_file(&new_client->dev, | ||
617 | &sensor_dev_attr_temp2_crit_hyst.dev_attr); | ||
618 | |||
619 | device_create_file(&new_client->dev, | ||
620 | &sensor_dev_attr_temp2_input_fault.dev_attr); | ||
621 | device_create_file(&new_client->dev, | ||
622 | &sensor_dev_attr_temp1_min_alarm.dev_attr); | ||
623 | device_create_file(&new_client->dev, | ||
624 | &sensor_dev_attr_temp2_min_alarm.dev_attr); | ||
625 | device_create_file(&new_client->dev, | ||
626 | &sensor_dev_attr_temp1_max_alarm.dev_attr); | ||
627 | device_create_file(&new_client->dev, | ||
628 | &sensor_dev_attr_temp2_max_alarm.dev_attr); | ||
629 | device_create_file(&new_client->dev, | ||
630 | &sensor_dev_attr_temp1_crit_alarm.dev_attr); | ||
631 | device_create_file(&new_client->dev, | ||
632 | &sensor_dev_attr_temp2_crit_alarm.dev_attr); | ||
633 | device_create_file(&new_client->dev, &dev_attr_alarms); | ||
634 | |||
635 | if (new_client->flags & I2C_CLIENT_PEC) | ||
636 | device_create_file(&new_client->dev, &dev_attr_pec); | ||
637 | |||
638 | return 0; | 634 | return 0; |
639 | 635 | ||
636 | exit_remove_files: | ||
637 | sysfs_remove_group(&new_client->dev.kobj, &lm90_group); | ||
638 | device_remove_file(&new_client->dev, &dev_attr_pec); | ||
640 | exit_detach: | 639 | exit_detach: |
641 | i2c_detach_client(new_client); | 640 | i2c_detach_client(new_client); |
642 | exit_free: | 641 | exit_free: |
@@ -669,6 +668,8 @@ static int lm90_detach_client(struct i2c_client *client) | |||
669 | int err; | 668 | int err; |
670 | 669 | ||
671 | hwmon_device_unregister(data->class_dev); | 670 | hwmon_device_unregister(data->class_dev); |
671 | sysfs_remove_group(&client->dev.kobj, &lm90_group); | ||
672 | device_remove_file(&client->dev, &dev_attr_pec); | ||
672 | 673 | ||
673 | if ((err = i2c_detach_client(client))) | 674 | if ((err = i2c_detach_client(client))) |
674 | return err; | 675 | return err; |