Commit 073f1e6c895f256b1d7b535a97fe0ced98ac1615

Authored by Guenter Roeck
Committed by Guenter Roeck
1 parent c6370dbe45

hwmon: (lm87) Fix: do not use assignment in if condition

Fix checkpatch issue:
ERROR: do not use assignment in if condition

Replace repeated calls to device_create_file() with calls to sysfs_create_group.

Cc: Jean Delvare <khali@linux-fr.org>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Acked-by: Jean Delvare <khali@linux-fr.org>

Showing 1 changed file with 82 additions and 72 deletions Side-by-side Diff

drivers/hwmon/lm87.c
... ... @@ -700,34 +700,69 @@
700 700 .attrs = lm87_attributes,
701 701 };
702 702  
703   -static struct attribute *lm87_attributes_opt[] = {
  703 +static struct attribute *lm87_attributes_in6[] = {
704 704 &dev_attr_in6_input.attr,
705 705 &dev_attr_in6_min.attr,
706 706 &dev_attr_in6_max.attr,
707 707 &sensor_dev_attr_in6_alarm.dev_attr.attr,
  708 + NULL
  709 +};
708 710  
  711 +static const struct attribute_group lm87_group_in6 = {
  712 + .attrs = lm87_attributes_in6,
  713 +};
  714 +
  715 +static struct attribute *lm87_attributes_fan1[] = {
709 716 &dev_attr_fan1_input.attr,
710 717 &dev_attr_fan1_min.attr,
711 718 &dev_attr_fan1_div.attr,
712 719 &sensor_dev_attr_fan1_alarm.dev_attr.attr,
  720 + NULL
  721 +};
713 722  
  723 +static const struct attribute_group lm87_group_fan1 = {
  724 + .attrs = lm87_attributes_fan1,
  725 +};
  726 +
  727 +static struct attribute *lm87_attributes_in7[] = {
714 728 &dev_attr_in7_input.attr,
715 729 &dev_attr_in7_min.attr,
716 730 &dev_attr_in7_max.attr,
717 731 &sensor_dev_attr_in7_alarm.dev_attr.attr,
  732 + NULL
  733 +};
718 734  
  735 +static const struct attribute_group lm87_group_in7 = {
  736 + .attrs = lm87_attributes_in7,
  737 +};
  738 +
  739 +static struct attribute *lm87_attributes_fan2[] = {
719 740 &dev_attr_fan2_input.attr,
720 741 &dev_attr_fan2_min.attr,
721 742 &dev_attr_fan2_div.attr,
722 743 &sensor_dev_attr_fan2_alarm.dev_attr.attr,
  744 + NULL
  745 +};
723 746  
  747 +static const struct attribute_group lm87_group_fan2 = {
  748 + .attrs = lm87_attributes_fan2,
  749 +};
  750 +
  751 +static struct attribute *lm87_attributes_temp3[] = {
724 752 &dev_attr_temp3_input.attr,
725 753 &dev_attr_temp3_max.attr,
726 754 &dev_attr_temp3_min.attr,
727 755 &dev_attr_temp3_crit.attr,
728 756 &sensor_dev_attr_temp3_alarm.dev_attr.attr,
729 757 &sensor_dev_attr_temp3_fault.dev_attr.attr,
  758 + NULL
  759 +};
730 760  
  761 +static const struct attribute_group lm87_group_temp3 = {
  762 + .attrs = lm87_attributes_temp3,
  763 +};
  764 +
  765 +static struct attribute *lm87_attributes_in0_5[] = {
731 766 &dev_attr_in0_input.attr,
732 767 &dev_attr_in0_min.attr,
733 768 &dev_attr_in0_max.attr,
734 769  
735 770  
736 771  
... ... @@ -736,15 +771,21 @@
736 771 &dev_attr_in5_min.attr,
737 772 &dev_attr_in5_max.attr,
738 773 &sensor_dev_attr_in5_alarm.dev_attr.attr,
  774 + NULL
  775 +};
739 776  
  777 +static const struct attribute_group lm87_group_in0_5 = {
  778 + .attrs = lm87_attributes_in0_5,
  779 +};
  780 +
  781 +static struct attribute *lm87_attributes_vid[] = {
740 782 &dev_attr_cpu0_vid.attr,
741 783 &dev_attr_vrm.attr,
742   -
743 784 NULL
744 785 };
745 786  
746   -static const struct attribute_group lm87_group_opt = {
747   - .attrs = lm87_attributes_opt,
  787 +static const struct attribute_group lm87_group_vid = {
  788 + .attrs = lm87_attributes_vid,
748 789 };
749 790  
750 791 /* Return 0 if detection is successful, -ENODEV otherwise */
... ... @@ -782,6 +823,20 @@
782 823 return 0;
783 824 }
784 825  
  826 +static void lm87_remove_files(struct i2c_client *client)
  827 +{
  828 + struct device *dev = &client->dev;
  829 +
  830 + sysfs_remove_group(&dev->kobj, &lm87_group);
  831 + sysfs_remove_group(&dev->kobj, &lm87_group_in6);
  832 + sysfs_remove_group(&dev->kobj, &lm87_group_fan1);
  833 + sysfs_remove_group(&dev->kobj, &lm87_group_in7);
  834 + sysfs_remove_group(&dev->kobj, &lm87_group_fan2);
  835 + sysfs_remove_group(&dev->kobj, &lm87_group_temp3);
  836 + sysfs_remove_group(&dev->kobj, &lm87_group_in0_5);
  837 + sysfs_remove_group(&dev->kobj, &lm87_group_vid);
  838 +}
  839 +
785 840 static int lm87_probe(struct i2c_client *new_client,
786 841 const struct i2c_device_id *id)
787 842 {
788 843  
789 844  
790 845  
791 846  
792 847  
793 848  
... ... @@ -816,89 +871,46 @@
816 871 goto exit_free;
817 872  
818 873 if (data->channel & CHAN_NO_FAN(0)) {
819   - if ((err = device_create_file(&new_client->dev,
820   - &dev_attr_in6_input))
821   - || (err = device_create_file(&new_client->dev,
822   - &dev_attr_in6_min))
823   - || (err = device_create_file(&new_client->dev,
824   - &dev_attr_in6_max))
825   - || (err = device_create_file(&new_client->dev,
826   - &sensor_dev_attr_in6_alarm.dev_attr)))
  874 + err = sysfs_create_group(&new_client->dev.kobj,
  875 + &lm87_group_in6);
  876 + if (err)
827 877 goto exit_remove;
828 878 } else {
829   - if ((err = device_create_file(&new_client->dev,
830   - &dev_attr_fan1_input))
831   - || (err = device_create_file(&new_client->dev,
832   - &dev_attr_fan1_min))
833   - || (err = device_create_file(&new_client->dev,
834   - &dev_attr_fan1_div))
835   - || (err = device_create_file(&new_client->dev,
836   - &sensor_dev_attr_fan1_alarm.dev_attr)))
  879 + err = sysfs_create_group(&new_client->dev.kobj,
  880 + &lm87_group_fan1);
  881 + if (err)
837 882 goto exit_remove;
838 883 }
839 884  
840 885 if (data->channel & CHAN_NO_FAN(1)) {
841   - if ((err = device_create_file(&new_client->dev,
842   - &dev_attr_in7_input))
843   - || (err = device_create_file(&new_client->dev,
844   - &dev_attr_in7_min))
845   - || (err = device_create_file(&new_client->dev,
846   - &dev_attr_in7_max))
847   - || (err = device_create_file(&new_client->dev,
848   - &sensor_dev_attr_in7_alarm.dev_attr)))
  886 + err = sysfs_create_group(&new_client->dev.kobj,
  887 + &lm87_group_in7);
  888 + if (err)
849 889 goto exit_remove;
850 890 } else {
851   - if ((err = device_create_file(&new_client->dev,
852   - &dev_attr_fan2_input))
853   - || (err = device_create_file(&new_client->dev,
854   - &dev_attr_fan2_min))
855   - || (err = device_create_file(&new_client->dev,
856   - &dev_attr_fan2_div))
857   - || (err = device_create_file(&new_client->dev,
858   - &sensor_dev_attr_fan2_alarm.dev_attr)))
  891 + err = sysfs_create_group(&new_client->dev.kobj,
  892 + &lm87_group_fan2);
  893 + if (err)
859 894 goto exit_remove;
860 895 }
861 896  
862 897 if (data->channel & CHAN_TEMP3) {
863   - if ((err = device_create_file(&new_client->dev,
864   - &dev_attr_temp3_input))
865   - || (err = device_create_file(&new_client->dev,
866   - &dev_attr_temp3_max))
867   - || (err = device_create_file(&new_client->dev,
868   - &dev_attr_temp3_min))
869   - || (err = device_create_file(&new_client->dev,
870   - &dev_attr_temp3_crit))
871   - || (err = device_create_file(&new_client->dev,
872   - &sensor_dev_attr_temp3_alarm.dev_attr))
873   - || (err = device_create_file(&new_client->dev,
874   - &sensor_dev_attr_temp3_fault.dev_attr)))
  898 + err = sysfs_create_group(&new_client->dev.kobj,
  899 + &lm87_group_temp3);
  900 + if (err)
875 901 goto exit_remove;
876 902 } else {
877   - if ((err = device_create_file(&new_client->dev,
878   - &dev_attr_in0_input))
879   - || (err = device_create_file(&new_client->dev,
880   - &dev_attr_in0_min))
881   - || (err = device_create_file(&new_client->dev,
882   - &dev_attr_in0_max))
883   - || (err = device_create_file(&new_client->dev,
884   - &sensor_dev_attr_in0_alarm.dev_attr))
885   - || (err = device_create_file(&new_client->dev,
886   - &dev_attr_in5_input))
887   - || (err = device_create_file(&new_client->dev,
888   - &dev_attr_in5_min))
889   - || (err = device_create_file(&new_client->dev,
890   - &dev_attr_in5_max))
891   - || (err = device_create_file(&new_client->dev,
892   - &sensor_dev_attr_in5_alarm.dev_attr)))
  903 + err = sysfs_create_group(&new_client->dev.kobj,
  904 + &lm87_group_in0_5);
  905 + if (err)
893 906 goto exit_remove;
894 907 }
895 908  
896 909 if (!(data->channel & CHAN_NO_VID)) {
897 910 data->vrm = vid_which_vrm();
898   - if ((err = device_create_file(&new_client->dev,
899   - &dev_attr_cpu0_vid))
900   - || (err = device_create_file(&new_client->dev,
901   - &dev_attr_vrm)))
  911 + err = sysfs_create_group(&new_client->dev.kobj,
  912 + &lm87_group_vid);
  913 + if (err)
902 914 goto exit_remove;
903 915 }
904 916  
... ... @@ -911,8 +923,7 @@
911 923 return 0;
912 924  
913 925 exit_remove:
914   - sysfs_remove_group(&new_client->dev.kobj, &lm87_group);
915   - sysfs_remove_group(&new_client->dev.kobj, &lm87_group_opt);
  926 + lm87_remove_files(new_client);
916 927 exit_free:
917 928 lm87_write_value(new_client, LM87_REG_CONFIG, data->config);
918 929 kfree(data);
... ... @@ -967,8 +978,7 @@
967 978 struct lm87_data *data = i2c_get_clientdata(client);
968 979  
969 980 hwmon_device_unregister(data->hwmon_dev);
970   - sysfs_remove_group(&client->dev.kobj, &lm87_group);
971   - sysfs_remove_group(&client->dev.kobj, &lm87_group_opt);
  981 + lm87_remove_files(client);
972 982  
973 983 lm87_write_value(client, LM87_REG_CONFIG, data->config);
974 984 kfree(data);