diff options
author | Mark M. Hoffman <mhoffman@lightlink.com> | 2006-09-24 15:14:35 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2006-09-28 18:31:17 -0400 |
commit | 0501a3816e5b778830fc2157a6d6bb11a965fc2c (patch) | |
tree | 9424b8b523ea1a9c1522babe2becd77b8c614494 /drivers/hwmon/lm87.c | |
parent | c18beb5b92b090cb424718a4f1771b1a9fad56de (diff) |
hwmon: Fix unchecked return status, batch 2
hwmon: Fix unchecked return status, batch 2
Fix up some hwmon drivers so that they no longer ignore return status
from device_create_file().
Signed-off-by: Mark M. Hoffman <mhoffman@lightlink.com>
Signed-off-by: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/hwmon/lm87.c')
-rw-r--r-- | drivers/hwmon/lm87.c | 191 |
1 files changed, 139 insertions, 52 deletions
diff --git a/drivers/hwmon/lm87.c b/drivers/hwmon/lm87.c index e6c1b638c971..3ce825489e34 100644 --- a/drivers/hwmon/lm87.c +++ b/drivers/hwmon/lm87.c | |||
@@ -542,6 +542,78 @@ static int lm87_attach_adapter(struct i2c_adapter *adapter) | |||
542 | return i2c_probe(adapter, &addr_data, lm87_detect); | 542 | return i2c_probe(adapter, &addr_data, lm87_detect); |
543 | } | 543 | } |
544 | 544 | ||
545 | static struct attribute *lm87_attributes[] = { | ||
546 | &dev_attr_in1_input.attr, | ||
547 | &dev_attr_in1_min.attr, | ||
548 | &dev_attr_in1_max.attr, | ||
549 | &dev_attr_in2_input.attr, | ||
550 | &dev_attr_in2_min.attr, | ||
551 | &dev_attr_in2_max.attr, | ||
552 | &dev_attr_in3_input.attr, | ||
553 | &dev_attr_in3_min.attr, | ||
554 | &dev_attr_in3_max.attr, | ||
555 | &dev_attr_in4_input.attr, | ||
556 | &dev_attr_in4_min.attr, | ||
557 | &dev_attr_in4_max.attr, | ||
558 | |||
559 | &dev_attr_temp1_input.attr, | ||
560 | &dev_attr_temp1_max.attr, | ||
561 | &dev_attr_temp1_min.attr, | ||
562 | &dev_attr_temp1_crit.attr, | ||
563 | &dev_attr_temp2_input.attr, | ||
564 | &dev_attr_temp2_max.attr, | ||
565 | &dev_attr_temp2_min.attr, | ||
566 | &dev_attr_temp2_crit.attr, | ||
567 | |||
568 | &dev_attr_alarms.attr, | ||
569 | &dev_attr_aout_output.attr, | ||
570 | |||
571 | NULL | ||
572 | }; | ||
573 | |||
574 | static const struct attribute_group lm87_group = { | ||
575 | .attrs = lm87_attributes, | ||
576 | }; | ||
577 | |||
578 | static struct attribute *lm87_attributes_opt[] = { | ||
579 | &dev_attr_in6_input.attr, | ||
580 | &dev_attr_in6_min.attr, | ||
581 | &dev_attr_in6_max.attr, | ||
582 | |||
583 | &dev_attr_fan1_input.attr, | ||
584 | &dev_attr_fan1_min.attr, | ||
585 | &dev_attr_fan1_div.attr, | ||
586 | |||
587 | &dev_attr_in7_input.attr, | ||
588 | &dev_attr_in7_min.attr, | ||
589 | &dev_attr_in7_max.attr, | ||
590 | |||
591 | &dev_attr_fan2_input.attr, | ||
592 | &dev_attr_fan2_min.attr, | ||
593 | &dev_attr_fan2_div.attr, | ||
594 | |||
595 | &dev_attr_temp3_input.attr, | ||
596 | &dev_attr_temp3_max.attr, | ||
597 | &dev_attr_temp3_min.attr, | ||
598 | &dev_attr_temp3_crit.attr, | ||
599 | |||
600 | &dev_attr_in0_input.attr, | ||
601 | &dev_attr_in0_min.attr, | ||
602 | &dev_attr_in0_max.attr, | ||
603 | &dev_attr_in5_input.attr, | ||
604 | &dev_attr_in5_min.attr, | ||
605 | &dev_attr_in5_max.attr, | ||
606 | |||
607 | &dev_attr_cpu0_vid.attr, | ||
608 | &dev_attr_vrm.attr, | ||
609 | |||
610 | NULL | ||
611 | }; | ||
612 | |||
613 | static const struct attribute_group lm87_group_opt = { | ||
614 | .attrs = lm87_attributes_opt, | ||
615 | }; | ||
616 | |||
545 | /* | 617 | /* |
546 | * The following function does more than just detection. If detection | 618 | * The following function does more than just detection. If detection |
547 | * succeeds, it also registers the new chip. | 619 | * succeeds, it also registers the new chip. |
@@ -609,77 +681,90 @@ static int lm87_detect(struct i2c_adapter *adapter, int address, int kind) | |||
609 | data->in_scale[7] = 1875; | 681 | data->in_scale[7] = 1875; |
610 | 682 | ||
611 | /* Register sysfs hooks */ | 683 | /* Register sysfs hooks */ |
612 | data->class_dev = hwmon_device_register(&new_client->dev); | 684 | if ((err = sysfs_create_group(&new_client->dev.kobj, &lm87_group))) |
613 | if (IS_ERR(data->class_dev)) { | ||
614 | err = PTR_ERR(data->class_dev); | ||
615 | goto exit_detach; | 685 | goto exit_detach; |
616 | } | ||
617 | |||
618 | device_create_file(&new_client->dev, &dev_attr_in1_input); | ||
619 | device_create_file(&new_client->dev, &dev_attr_in1_min); | ||
620 | device_create_file(&new_client->dev, &dev_attr_in1_max); | ||
621 | device_create_file(&new_client->dev, &dev_attr_in2_input); | ||
622 | device_create_file(&new_client->dev, &dev_attr_in2_min); | ||
623 | device_create_file(&new_client->dev, &dev_attr_in2_max); | ||
624 | device_create_file(&new_client->dev, &dev_attr_in3_input); | ||
625 | device_create_file(&new_client->dev, &dev_attr_in3_min); | ||
626 | device_create_file(&new_client->dev, &dev_attr_in3_max); | ||
627 | device_create_file(&new_client->dev, &dev_attr_in4_input); | ||
628 | device_create_file(&new_client->dev, &dev_attr_in4_min); | ||
629 | device_create_file(&new_client->dev, &dev_attr_in4_max); | ||
630 | 686 | ||
631 | if (data->channel & CHAN_NO_FAN(0)) { | 687 | if (data->channel & CHAN_NO_FAN(0)) { |
632 | device_create_file(&new_client->dev, &dev_attr_in6_input); | 688 | if ((err = device_create_file(&new_client->dev, |
633 | device_create_file(&new_client->dev, &dev_attr_in6_min); | 689 | &dev_attr_in6_input)) |
634 | device_create_file(&new_client->dev, &dev_attr_in6_max); | 690 | || (err = device_create_file(&new_client->dev, |
691 | &dev_attr_in6_min)) | ||
692 | || (err = device_create_file(&new_client->dev, | ||
693 | &dev_attr_in6_max))) | ||
694 | goto exit_remove; | ||
635 | } else { | 695 | } else { |
636 | device_create_file(&new_client->dev, &dev_attr_fan1_input); | 696 | if ((err = device_create_file(&new_client->dev, |
637 | device_create_file(&new_client->dev, &dev_attr_fan1_min); | 697 | &dev_attr_fan1_input)) |
638 | device_create_file(&new_client->dev, &dev_attr_fan1_div); | 698 | || (err = device_create_file(&new_client->dev, |
699 | &dev_attr_fan1_min)) | ||
700 | || (err = device_create_file(&new_client->dev, | ||
701 | &dev_attr_fan1_div))) | ||
702 | goto exit_remove; | ||
639 | } | 703 | } |
704 | |||
640 | if (data->channel & CHAN_NO_FAN(1)) { | 705 | if (data->channel & CHAN_NO_FAN(1)) { |
641 | device_create_file(&new_client->dev, &dev_attr_in7_input); | 706 | if ((err = device_create_file(&new_client->dev, |
642 | device_create_file(&new_client->dev, &dev_attr_in7_min); | 707 | &dev_attr_in7_input)) |
643 | device_create_file(&new_client->dev, &dev_attr_in7_max); | 708 | || (err = device_create_file(&new_client->dev, |
709 | &dev_attr_in7_min)) | ||
710 | || (err = device_create_file(&new_client->dev, | ||
711 | &dev_attr_in7_max))) | ||
712 | goto exit_remove; | ||
644 | } else { | 713 | } else { |
645 | device_create_file(&new_client->dev, &dev_attr_fan2_input); | 714 | if ((err = device_create_file(&new_client->dev, |
646 | device_create_file(&new_client->dev, &dev_attr_fan2_min); | 715 | &dev_attr_fan2_input)) |
647 | device_create_file(&new_client->dev, &dev_attr_fan2_div); | 716 | || (err = device_create_file(&new_client->dev, |
717 | &dev_attr_fan2_min)) | ||
718 | || (err = device_create_file(&new_client->dev, | ||
719 | &dev_attr_fan2_div))) | ||
720 | goto exit_remove; | ||
648 | } | 721 | } |
649 | 722 | ||
650 | device_create_file(&new_client->dev, &dev_attr_temp1_input); | ||
651 | device_create_file(&new_client->dev, &dev_attr_temp1_max); | ||
652 | device_create_file(&new_client->dev, &dev_attr_temp1_min); | ||
653 | device_create_file(&new_client->dev, &dev_attr_temp1_crit); | ||
654 | device_create_file(&new_client->dev, &dev_attr_temp2_input); | ||
655 | device_create_file(&new_client->dev, &dev_attr_temp2_max); | ||
656 | device_create_file(&new_client->dev, &dev_attr_temp2_min); | ||
657 | device_create_file(&new_client->dev, &dev_attr_temp2_crit); | ||
658 | |||
659 | if (data->channel & CHAN_TEMP3) { | 723 | if (data->channel & CHAN_TEMP3) { |
660 | device_create_file(&new_client->dev, &dev_attr_temp3_input); | 724 | if ((err = device_create_file(&new_client->dev, |
661 | device_create_file(&new_client->dev, &dev_attr_temp3_max); | 725 | &dev_attr_temp3_input)) |
662 | device_create_file(&new_client->dev, &dev_attr_temp3_min); | 726 | || (err = device_create_file(&new_client->dev, |
663 | device_create_file(&new_client->dev, &dev_attr_temp3_crit); | 727 | &dev_attr_temp3_max)) |
728 | || (err = device_create_file(&new_client->dev, | ||
729 | &dev_attr_temp3_min)) | ||
730 | || (err = device_create_file(&new_client->dev, | ||
731 | &dev_attr_temp3_crit))) | ||
732 | goto exit_remove; | ||
664 | } else { | 733 | } else { |
665 | device_create_file(&new_client->dev, &dev_attr_in0_input); | 734 | if ((err = device_create_file(&new_client->dev, |
666 | device_create_file(&new_client->dev, &dev_attr_in0_min); | 735 | &dev_attr_in0_input)) |
667 | device_create_file(&new_client->dev, &dev_attr_in0_max); | 736 | || (err = device_create_file(&new_client->dev, |
668 | device_create_file(&new_client->dev, &dev_attr_in5_input); | 737 | &dev_attr_in0_min)) |
669 | device_create_file(&new_client->dev, &dev_attr_in5_min); | 738 | || (err = device_create_file(&new_client->dev, |
670 | device_create_file(&new_client->dev, &dev_attr_in5_max); | 739 | &dev_attr_in0_max)) |
740 | || (err = device_create_file(&new_client->dev, | ||
741 | &dev_attr_in5_input)) | ||
742 | || (err = device_create_file(&new_client->dev, | ||
743 | &dev_attr_in5_min)) | ||
744 | || (err = device_create_file(&new_client->dev, | ||
745 | &dev_attr_in5_max))) | ||
746 | goto exit_remove; | ||
671 | } | 747 | } |
672 | 748 | ||
673 | if (!(data->channel & CHAN_NO_VID)) { | 749 | if (!(data->channel & CHAN_NO_VID)) { |
674 | device_create_file(&new_client->dev, &dev_attr_cpu0_vid); | 750 | if ((err = device_create_file(&new_client->dev, |
675 | device_create_file(&new_client->dev, &dev_attr_vrm); | 751 | &dev_attr_cpu0_vid)) |
752 | || (err = device_create_file(&new_client->dev, | ||
753 | &dev_attr_vrm))) | ||
754 | goto exit_remove; | ||
676 | } | 755 | } |
677 | 756 | ||
678 | device_create_file(&new_client->dev, &dev_attr_alarms); | 757 | data->class_dev = hwmon_device_register(&new_client->dev); |
679 | device_create_file(&new_client->dev, &dev_attr_aout_output); | 758 | if (IS_ERR(data->class_dev)) { |
759 | err = PTR_ERR(data->class_dev); | ||
760 | goto exit_remove; | ||
761 | } | ||
680 | 762 | ||
681 | return 0; | 763 | return 0; |
682 | 764 | ||
765 | exit_remove: | ||
766 | sysfs_remove_group(&new_client->dev.kobj, &lm87_group); | ||
767 | sysfs_remove_group(&new_client->dev.kobj, &lm87_group_opt); | ||
683 | exit_detach: | 768 | exit_detach: |
684 | i2c_detach_client(new_client); | 769 | i2c_detach_client(new_client); |
685 | exit_free: | 770 | exit_free: |
@@ -732,6 +817,8 @@ static int lm87_detach_client(struct i2c_client *client) | |||
732 | int err; | 817 | int err; |
733 | 818 | ||
734 | hwmon_device_unregister(data->class_dev); | 819 | hwmon_device_unregister(data->class_dev); |
820 | sysfs_remove_group(&client->dev.kobj, &lm87_group); | ||
821 | sysfs_remove_group(&client->dev.kobj, &lm87_group_opt); | ||
735 | 822 | ||
736 | if ((err = i2c_detach_client(client))) | 823 | if ((err = i2c_detach_client(client))) |
737 | return err; | 824 | return err; |