diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-01-16 23:45:16 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-18 21:27:37 -0400 |
commit | 795013333b613ba79b7df57515c9afacac6f167d (patch) | |
tree | 3bf1d5a152d9ccaa84a4f806d82c81204a9a76ac /drivers/hwmon/w83781d.c | |
parent | aff6e00ee142d04ffeb8d8dcd3b2c0b8f789c354 (diff) |
hwmon: (w83781d) 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.
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/w83781d.c')
-rw-r--r-- | drivers/hwmon/w83781d.c | 140 |
1 files changed, 72 insertions, 68 deletions
diff --git a/drivers/hwmon/w83781d.c b/drivers/hwmon/w83781d.c index cbed525a425f..b03d54a799e3 100644 --- a/drivers/hwmon/w83781d.c +++ b/drivers/hwmon/w83781d.c | |||
@@ -975,23 +975,58 @@ static const struct attribute_group w83781d_group = { | |||
975 | .attrs = w83781d_attributes, | 975 | .attrs = w83781d_attributes, |
976 | }; | 976 | }; |
977 | 977 | ||
978 | static struct attribute *w83781d_attributes_opt[] = { | 978 | static struct attribute *w83781d_attributes_in1[] = { |
979 | IN_UNIT_ATTRS(1), | 979 | IN_UNIT_ATTRS(1), |
980 | NULL | ||
981 | }; | ||
982 | static const struct attribute_group w83781d_group_in1 = { | ||
983 | .attrs = w83781d_attributes_in1, | ||
984 | }; | ||
985 | |||
986 | static struct attribute *w83781d_attributes_in78[] = { | ||
980 | IN_UNIT_ATTRS(7), | 987 | IN_UNIT_ATTRS(7), |
981 | IN_UNIT_ATTRS(8), | 988 | IN_UNIT_ATTRS(8), |
989 | NULL | ||
990 | }; | ||
991 | static const struct attribute_group w83781d_group_in78 = { | ||
992 | .attrs = w83781d_attributes_in78, | ||
993 | }; | ||
994 | |||
995 | static struct attribute *w83781d_attributes_temp3[] = { | ||
982 | TEMP_UNIT_ATTRS(3), | 996 | TEMP_UNIT_ATTRS(3), |
997 | NULL | ||
998 | }; | ||
999 | static const struct attribute_group w83781d_group_temp3 = { | ||
1000 | .attrs = w83781d_attributes_temp3, | ||
1001 | }; | ||
1002 | |||
1003 | static struct attribute *w83781d_attributes_pwm12[] = { | ||
983 | &sensor_dev_attr_pwm1.dev_attr.attr, | 1004 | &sensor_dev_attr_pwm1.dev_attr.attr, |
984 | &sensor_dev_attr_pwm2.dev_attr.attr, | 1005 | &sensor_dev_attr_pwm2.dev_attr.attr, |
1006 | &dev_attr_pwm2_enable.attr, | ||
1007 | NULL | ||
1008 | }; | ||
1009 | static const struct attribute_group w83781d_group_pwm12 = { | ||
1010 | .attrs = w83781d_attributes_pwm12, | ||
1011 | }; | ||
1012 | |||
1013 | static struct attribute *w83781d_attributes_pwm34[] = { | ||
985 | &sensor_dev_attr_pwm3.dev_attr.attr, | 1014 | &sensor_dev_attr_pwm3.dev_attr.attr, |
986 | &sensor_dev_attr_pwm4.dev_attr.attr, | 1015 | &sensor_dev_attr_pwm4.dev_attr.attr, |
987 | &dev_attr_pwm2_enable.attr, | 1016 | NULL |
1017 | }; | ||
1018 | static const struct attribute_group w83781d_group_pwm34 = { | ||
1019 | .attrs = w83781d_attributes_pwm34, | ||
1020 | }; | ||
1021 | |||
1022 | static struct attribute *w83781d_attributes_other[] = { | ||
988 | &sensor_dev_attr_temp1_type.dev_attr.attr, | 1023 | &sensor_dev_attr_temp1_type.dev_attr.attr, |
989 | &sensor_dev_attr_temp2_type.dev_attr.attr, | 1024 | &sensor_dev_attr_temp2_type.dev_attr.attr, |
990 | &sensor_dev_attr_temp3_type.dev_attr.attr, | 1025 | &sensor_dev_attr_temp3_type.dev_attr.attr, |
991 | NULL | 1026 | NULL |
992 | }; | 1027 | }; |
993 | static const struct attribute_group w83781d_group_opt = { | 1028 | static const struct attribute_group w83781d_group_other = { |
994 | .attrs = w83781d_attributes_opt, | 1029 | .attrs = w83781d_attributes_other, |
995 | }; | 1030 | }; |
996 | 1031 | ||
997 | /* No clean up is done on error, it's up to the caller */ | 1032 | /* No clean up is done on error, it's up to the caller */ |
@@ -1005,52 +1040,18 @@ w83781d_create_files(struct device *dev, int kind, int is_isa) | |||
1005 | return err; | 1040 | return err; |
1006 | 1041 | ||
1007 | if (kind != w83783s) { | 1042 | if (kind != w83783s) { |
1008 | if ((err = device_create_file(dev, | 1043 | err = sysfs_create_group(&dev->kobj, &w83781d_group_in1); |
1009 | &sensor_dev_attr_in1_input.dev_attr)) | 1044 | if (err) |
1010 | || (err = device_create_file(dev, | ||
1011 | &sensor_dev_attr_in1_min.dev_attr)) | ||
1012 | || (err = device_create_file(dev, | ||
1013 | &sensor_dev_attr_in1_max.dev_attr)) | ||
1014 | || (err = device_create_file(dev, | ||
1015 | &sensor_dev_attr_in1_alarm.dev_attr)) | ||
1016 | || (err = device_create_file(dev, | ||
1017 | &sensor_dev_attr_in1_beep.dev_attr))) | ||
1018 | return err; | 1045 | return err; |
1019 | } | 1046 | } |
1020 | if (kind != as99127f && kind != w83781d && kind != w83783s) { | 1047 | if (kind != as99127f && kind != w83781d && kind != w83783s) { |
1021 | if ((err = device_create_file(dev, | 1048 | err = sysfs_create_group(&dev->kobj, &w83781d_group_in78); |
1022 | &sensor_dev_attr_in7_input.dev_attr)) | 1049 | if (err) |
1023 | || (err = device_create_file(dev, | ||
1024 | &sensor_dev_attr_in7_min.dev_attr)) | ||
1025 | || (err = device_create_file(dev, | ||
1026 | &sensor_dev_attr_in7_max.dev_attr)) | ||
1027 | || (err = device_create_file(dev, | ||
1028 | &sensor_dev_attr_in7_alarm.dev_attr)) | ||
1029 | || (err = device_create_file(dev, | ||
1030 | &sensor_dev_attr_in7_beep.dev_attr)) | ||
1031 | || (err = device_create_file(dev, | ||
1032 | &sensor_dev_attr_in8_input.dev_attr)) | ||
1033 | || (err = device_create_file(dev, | ||
1034 | &sensor_dev_attr_in8_min.dev_attr)) | ||
1035 | || (err = device_create_file(dev, | ||
1036 | &sensor_dev_attr_in8_max.dev_attr)) | ||
1037 | || (err = device_create_file(dev, | ||
1038 | &sensor_dev_attr_in8_alarm.dev_attr)) | ||
1039 | || (err = device_create_file(dev, | ||
1040 | &sensor_dev_attr_in8_beep.dev_attr))) | ||
1041 | return err; | 1050 | return err; |
1042 | } | 1051 | } |
1043 | if (kind != w83783s) { | 1052 | if (kind != w83783s) { |
1044 | if ((err = device_create_file(dev, | 1053 | err = sysfs_create_group(&dev->kobj, &w83781d_group_temp3); |
1045 | &sensor_dev_attr_temp3_input.dev_attr)) | 1054 | if (err) |
1046 | || (err = device_create_file(dev, | ||
1047 | &sensor_dev_attr_temp3_max.dev_attr)) | ||
1048 | || (err = device_create_file(dev, | ||
1049 | &sensor_dev_attr_temp3_max_hyst.dev_attr)) | ||
1050 | || (err = device_create_file(dev, | ||
1051 | &sensor_dev_attr_temp3_alarm.dev_attr)) | ||
1052 | || (err = device_create_file(dev, | ||
1053 | &sensor_dev_attr_temp3_beep.dev_attr))) | ||
1054 | return err; | 1055 | return err; |
1055 | 1056 | ||
1056 | if (kind != w83781d) { | 1057 | if (kind != w83781d) { |
@@ -1063,30 +1064,28 @@ w83781d_create_files(struct device *dev, int kind, int is_isa) | |||
1063 | } | 1064 | } |
1064 | 1065 | ||
1065 | if (kind != w83781d && kind != as99127f) { | 1066 | if (kind != w83781d && kind != as99127f) { |
1066 | if ((err = device_create_file(dev, | 1067 | err = sysfs_create_group(&dev->kobj, &w83781d_group_pwm12); |
1067 | &sensor_dev_attr_pwm1.dev_attr)) | 1068 | if (err) |
1068 | || (err = device_create_file(dev, | ||
1069 | &sensor_dev_attr_pwm2.dev_attr)) | ||
1070 | || (err = device_create_file(dev, &dev_attr_pwm2_enable))) | ||
1071 | return err; | 1069 | return err; |
1072 | } | 1070 | } |
1073 | if (kind == w83782d && !is_isa) { | 1071 | if (kind == w83782d && !is_isa) { |
1074 | if ((err = device_create_file(dev, | 1072 | err = sysfs_create_group(&dev->kobj, &w83781d_group_pwm34); |
1075 | &sensor_dev_attr_pwm3.dev_attr)) | 1073 | if (err) |
1076 | || (err = device_create_file(dev, | ||
1077 | &sensor_dev_attr_pwm4.dev_attr))) | ||
1078 | return err; | 1074 | return err; |
1079 | } | 1075 | } |
1080 | 1076 | ||
1081 | if (kind != as99127f && kind != w83781d) { | 1077 | if (kind != as99127f && kind != w83781d) { |
1082 | if ((err = device_create_file(dev, | 1078 | err = device_create_file(dev, |
1083 | &sensor_dev_attr_temp1_type.dev_attr)) | 1079 | &sensor_dev_attr_temp1_type.dev_attr); |
1084 | || (err = device_create_file(dev, | 1080 | if (err) |
1085 | &sensor_dev_attr_temp2_type.dev_attr))) | 1081 | return err; |
1082 | err = device_create_file(dev, | ||
1083 | &sensor_dev_attr_temp2_type.dev_attr); | ||
1084 | if (err) | ||
1086 | return err; | 1085 | return err; |
1087 | if (kind != w83783s) { | 1086 | if (kind != w83783s) { |
1088 | err = device_create_file(dev, | 1087 | err = device_create_file(dev, |
1089 | &sensor_dev_attr_temp3_type.dev_attr); | 1088 | &sensor_dev_attr_temp3_type.dev_attr); |
1090 | if (err) | 1089 | if (err) |
1091 | return err; | 1090 | return err; |
1092 | } | 1091 | } |
@@ -1196,6 +1195,17 @@ w83781d_detect(struct i2c_client *client, struct i2c_board_info *info) | |||
1196 | return -ENODEV; | 1195 | return -ENODEV; |
1197 | } | 1196 | } |
1198 | 1197 | ||
1198 | static void w83781d_remove_files(struct device *dev) | ||
1199 | { | ||
1200 | sysfs_remove_group(&dev->kobj, &w83781d_group); | ||
1201 | sysfs_remove_group(&dev->kobj, &w83781d_group_in1); | ||
1202 | sysfs_remove_group(&dev->kobj, &w83781d_group_in78); | ||
1203 | sysfs_remove_group(&dev->kobj, &w83781d_group_temp3); | ||
1204 | sysfs_remove_group(&dev->kobj, &w83781d_group_pwm12); | ||
1205 | sysfs_remove_group(&dev->kobj, &w83781d_group_pwm34); | ||
1206 | sysfs_remove_group(&dev->kobj, &w83781d_group_other); | ||
1207 | } | ||
1208 | |||
1199 | static int | 1209 | static int |
1200 | w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id) | 1210 | w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id) |
1201 | { | 1211 | { |
@@ -1238,9 +1248,7 @@ w83781d_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
1238 | return 0; | 1248 | return 0; |
1239 | 1249 | ||
1240 | ERROR4: | 1250 | ERROR4: |
1241 | sysfs_remove_group(&dev->kobj, &w83781d_group); | 1251 | w83781d_remove_files(dev); |
1242 | sysfs_remove_group(&dev->kobj, &w83781d_group_opt); | ||
1243 | |||
1244 | if (data->lm75[0]) | 1252 | if (data->lm75[0]) |
1245 | i2c_unregister_device(data->lm75[0]); | 1253 | i2c_unregister_device(data->lm75[0]); |
1246 | if (data->lm75[1]) | 1254 | if (data->lm75[1]) |
@@ -1258,9 +1266,7 @@ w83781d_remove(struct i2c_client *client) | |||
1258 | struct device *dev = &client->dev; | 1266 | struct device *dev = &client->dev; |
1259 | 1267 | ||
1260 | hwmon_device_unregister(data->hwmon_dev); | 1268 | hwmon_device_unregister(data->hwmon_dev); |
1261 | 1269 | w83781d_remove_files(dev); | |
1262 | sysfs_remove_group(&dev->kobj, &w83781d_group); | ||
1263 | sysfs_remove_group(&dev->kobj, &w83781d_group_opt); | ||
1264 | 1270 | ||
1265 | if (data->lm75[0]) | 1271 | if (data->lm75[0]) |
1266 | i2c_unregister_device(data->lm75[0]); | 1272 | i2c_unregister_device(data->lm75[0]); |
@@ -1821,8 +1827,7 @@ w83781d_isa_probe(struct platform_device *pdev) | |||
1821 | return 0; | 1827 | return 0; |
1822 | 1828 | ||
1823 | exit_remove_files: | 1829 | exit_remove_files: |
1824 | sysfs_remove_group(&pdev->dev.kobj, &w83781d_group); | 1830 | w83781d_remove_files(&pdev->dev); |
1825 | sysfs_remove_group(&pdev->dev.kobj, &w83781d_group_opt); | ||
1826 | device_remove_file(&pdev->dev, &dev_attr_name); | 1831 | device_remove_file(&pdev->dev, &dev_attr_name); |
1827 | kfree(data); | 1832 | kfree(data); |
1828 | exit_release_region: | 1833 | exit_release_region: |
@@ -1837,8 +1842,7 @@ w83781d_isa_remove(struct platform_device *pdev) | |||
1837 | struct w83781d_data *data = platform_get_drvdata(pdev); | 1842 | struct w83781d_data *data = platform_get_drvdata(pdev); |
1838 | 1843 | ||
1839 | hwmon_device_unregister(data->hwmon_dev); | 1844 | hwmon_device_unregister(data->hwmon_dev); |
1840 | sysfs_remove_group(&pdev->dev.kobj, &w83781d_group); | 1845 | w83781d_remove_files(&pdev->dev); |
1841 | sysfs_remove_group(&pdev->dev.kobj, &w83781d_group_opt); | ||
1842 | device_remove_file(&pdev->dev, &dev_attr_name); | 1846 | device_remove_file(&pdev->dev, &dev_attr_name); |
1843 | release_region(data->isa_addr + W83781D_ADDR_REG_OFFSET, 2); | 1847 | release_region(data->isa_addr + W83781D_ADDR_REG_OFFSET, 2); |
1844 | kfree(data); | 1848 | kfree(data); |