diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-01-20 00:49:20 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-18 21:27:29 -0400 |
commit | 2185696d7d8a852146f6a901b35e9b94be43329a (patch) | |
tree | b3f75fc6188622e689ef3e7507cc485e9b9ddcdf | |
parent | b162c033480a7ba0433d329f56c142a0ab59049d (diff) |
hwmon: (vt1211) 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: Juerg Haefliger <juergh@gmail.com>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/vt1211.c | 227 |
1 files changed, 94 insertions, 133 deletions
diff --git a/drivers/hwmon/vt1211.c b/drivers/hwmon/vt1211.c index 5de5f72a8202..c2c5c72fb8f0 100644 --- a/drivers/hwmon/vt1211.c +++ b/drivers/hwmon/vt1211.c | |||
@@ -909,112 +909,99 @@ static ssize_t show_alarms(struct device *dev, | |||
909 | * Device attribute structs | 909 | * Device attribute structs |
910 | * --------------------------------------------------------------------- */ | 910 | * --------------------------------------------------------------------- */ |
911 | 911 | ||
912 | #define SENSOR_ATTR_IN_INPUT(ix) \ | 912 | #define SENSOR_ATTR_IN(ix) \ |
913 | SENSOR_ATTR_2(in##ix##_input, S_IRUGO, \ | 913 | { SENSOR_ATTR_2(in##ix##_input, S_IRUGO, \ |
914 | show_in, NULL, SHOW_IN_INPUT, ix) | 914 | show_in, NULL, SHOW_IN_INPUT, ix), \ |
915 | |||
916 | static struct sensor_device_attribute_2 vt1211_sysfs_in_input[] = { | ||
917 | SENSOR_ATTR_IN_INPUT(0), | ||
918 | SENSOR_ATTR_IN_INPUT(1), | ||
919 | SENSOR_ATTR_IN_INPUT(2), | ||
920 | SENSOR_ATTR_IN_INPUT(3), | ||
921 | SENSOR_ATTR_IN_INPUT(4), | ||
922 | SENSOR_ATTR_IN_INPUT(5), | ||
923 | }; | ||
924 | |||
925 | #define SENSOR_ATTR_IN_MIN(ix) \ | ||
926 | SENSOR_ATTR_2(in##ix##_min, S_IRUGO | S_IWUSR, \ | 915 | SENSOR_ATTR_2(in##ix##_min, S_IRUGO | S_IWUSR, \ |
927 | show_in, set_in, SHOW_SET_IN_MIN, ix) | 916 | show_in, set_in, SHOW_SET_IN_MIN, ix), \ |
928 | |||
929 | static struct sensor_device_attribute_2 vt1211_sysfs_in_min[] = { | ||
930 | SENSOR_ATTR_IN_MIN(0), | ||
931 | SENSOR_ATTR_IN_MIN(1), | ||
932 | SENSOR_ATTR_IN_MIN(2), | ||
933 | SENSOR_ATTR_IN_MIN(3), | ||
934 | SENSOR_ATTR_IN_MIN(4), | ||
935 | SENSOR_ATTR_IN_MIN(5), | ||
936 | }; | ||
937 | |||
938 | #define SENSOR_ATTR_IN_MAX(ix) \ | ||
939 | SENSOR_ATTR_2(in##ix##_max, S_IRUGO | S_IWUSR, \ | 917 | SENSOR_ATTR_2(in##ix##_max, S_IRUGO | S_IWUSR, \ |
940 | show_in, set_in, SHOW_SET_IN_MAX, ix) | 918 | show_in, set_in, SHOW_SET_IN_MAX, ix), \ |
941 | 919 | SENSOR_ATTR_2(in##ix##_alarm, S_IRUGO, \ | |
942 | static struct sensor_device_attribute_2 vt1211_sysfs_in_max[] = { | 920 | show_in, NULL, SHOW_IN_ALARM, ix) \ |
943 | SENSOR_ATTR_IN_MAX(0), | 921 | } |
944 | SENSOR_ATTR_IN_MAX(1), | 922 | |
945 | SENSOR_ATTR_IN_MAX(2), | 923 | static struct sensor_device_attribute_2 vt1211_sysfs_in[][4] = { |
946 | SENSOR_ATTR_IN_MAX(3), | 924 | SENSOR_ATTR_IN(0), |
947 | SENSOR_ATTR_IN_MAX(4), | 925 | SENSOR_ATTR_IN(1), |
948 | SENSOR_ATTR_IN_MAX(5), | 926 | SENSOR_ATTR_IN(2), |
927 | SENSOR_ATTR_IN(3), | ||
928 | SENSOR_ATTR_IN(4), | ||
929 | SENSOR_ATTR_IN(5) | ||
949 | }; | 930 | }; |
950 | 931 | ||
951 | #define SENSOR_ATTR_IN_ALARM(ix) \ | 932 | #define IN_UNIT_ATTRS(X) \ |
952 | SENSOR_ATTR_2(in##ix##_alarm, S_IRUGO, \ | 933 | { &vt1211_sysfs_in[X][0].dev_attr.attr, \ |
953 | show_in, NULL, SHOW_IN_ALARM, ix) | 934 | &vt1211_sysfs_in[X][1].dev_attr.attr, \ |
954 | 935 | &vt1211_sysfs_in[X][2].dev_attr.attr, \ | |
955 | static struct sensor_device_attribute_2 vt1211_sysfs_in_alarm[] = { | 936 | &vt1211_sysfs_in[X][3].dev_attr.attr, \ |
956 | SENSOR_ATTR_IN_ALARM(0), | 937 | NULL \ |
957 | SENSOR_ATTR_IN_ALARM(1), | 938 | } |
958 | SENSOR_ATTR_IN_ALARM(2), | 939 | |
959 | SENSOR_ATTR_IN_ALARM(3), | 940 | static struct attribute *vt1211_in_attr[][5] = { |
960 | SENSOR_ATTR_IN_ALARM(4), | 941 | IN_UNIT_ATTRS(0), |
961 | SENSOR_ATTR_IN_ALARM(5), | 942 | IN_UNIT_ATTRS(1), |
943 | IN_UNIT_ATTRS(2), | ||
944 | IN_UNIT_ATTRS(3), | ||
945 | IN_UNIT_ATTRS(4), | ||
946 | IN_UNIT_ATTRS(5) | ||
962 | }; | 947 | }; |
963 | 948 | ||
964 | #define SENSOR_ATTR_TEMP_INPUT(ix) \ | 949 | static const struct attribute_group vt1211_in_attr_group[] = { |
965 | SENSOR_ATTR_2(temp##ix##_input, S_IRUGO, \ | 950 | { .attrs = vt1211_in_attr[0] }, |
966 | show_temp, NULL, SHOW_TEMP_INPUT, ix-1) | 951 | { .attrs = vt1211_in_attr[1] }, |
967 | 952 | { .attrs = vt1211_in_attr[2] }, | |
968 | static struct sensor_device_attribute_2 vt1211_sysfs_temp_input[] = { | 953 | { .attrs = vt1211_in_attr[3] }, |
969 | SENSOR_ATTR_TEMP_INPUT(1), | 954 | { .attrs = vt1211_in_attr[4] }, |
970 | SENSOR_ATTR_TEMP_INPUT(2), | 955 | { .attrs = vt1211_in_attr[5] } |
971 | SENSOR_ATTR_TEMP_INPUT(3), | ||
972 | SENSOR_ATTR_TEMP_INPUT(4), | ||
973 | SENSOR_ATTR_TEMP_INPUT(5), | ||
974 | SENSOR_ATTR_TEMP_INPUT(6), | ||
975 | SENSOR_ATTR_TEMP_INPUT(7), | ||
976 | }; | 956 | }; |
977 | 957 | ||
978 | #define SENSOR_ATTR_TEMP_MAX(ix) \ | 958 | #define SENSOR_ATTR_TEMP(ix) \ |
959 | { SENSOR_ATTR_2(temp##ix##_input, S_IRUGO, \ | ||
960 | show_temp, NULL, SHOW_TEMP_INPUT, ix-1), \ | ||
979 | SENSOR_ATTR_2(temp##ix##_max, S_IRUGO | S_IWUSR, \ | 961 | SENSOR_ATTR_2(temp##ix##_max, S_IRUGO | S_IWUSR, \ |
980 | show_temp, set_temp, SHOW_SET_TEMP_MAX, ix-1) | 962 | show_temp, set_temp, SHOW_SET_TEMP_MAX, ix-1), \ |
981 | 963 | SENSOR_ATTR_2(temp##ix##_max_hyst, S_IRUGO | S_IWUSR, \ | |
982 | static struct sensor_device_attribute_2 vt1211_sysfs_temp_max[] = { | 964 | show_temp, set_temp, SHOW_SET_TEMP_MAX_HYST, ix-1), \ |
983 | SENSOR_ATTR_TEMP_MAX(1), | 965 | SENSOR_ATTR_2(temp##ix##_alarm, S_IRUGO, \ |
984 | SENSOR_ATTR_TEMP_MAX(2), | 966 | show_temp, NULL, SHOW_TEMP_ALARM, ix-1) \ |
985 | SENSOR_ATTR_TEMP_MAX(3), | 967 | } |
986 | SENSOR_ATTR_TEMP_MAX(4), | 968 | |
987 | SENSOR_ATTR_TEMP_MAX(5), | 969 | static struct sensor_device_attribute_2 vt1211_sysfs_temp[][4] = { |
988 | SENSOR_ATTR_TEMP_MAX(6), | 970 | SENSOR_ATTR_TEMP(1), |
989 | SENSOR_ATTR_TEMP_MAX(7), | 971 | SENSOR_ATTR_TEMP(2), |
972 | SENSOR_ATTR_TEMP(3), | ||
973 | SENSOR_ATTR_TEMP(4), | ||
974 | SENSOR_ATTR_TEMP(5), | ||
975 | SENSOR_ATTR_TEMP(6), | ||
976 | SENSOR_ATTR_TEMP(7), | ||
990 | }; | 977 | }; |
991 | 978 | ||
992 | #define SENSOR_ATTR_TEMP_MAX_HYST(ix) \ | 979 | #define TEMP_UNIT_ATTRS(X) \ |
993 | SENSOR_ATTR_2(temp##ix##_max_hyst, S_IRUGO | S_IWUSR, \ | 980 | { &vt1211_sysfs_temp[X][0].dev_attr.attr, \ |
994 | show_temp, set_temp, SHOW_SET_TEMP_MAX_HYST, ix-1) | 981 | &vt1211_sysfs_temp[X][1].dev_attr.attr, \ |
995 | 982 | &vt1211_sysfs_temp[X][2].dev_attr.attr, \ | |
996 | static struct sensor_device_attribute_2 vt1211_sysfs_temp_max_hyst[] = { | 983 | &vt1211_sysfs_temp[X][3].dev_attr.attr, \ |
997 | SENSOR_ATTR_TEMP_MAX_HYST(1), | 984 | NULL \ |
998 | SENSOR_ATTR_TEMP_MAX_HYST(2), | 985 | } |
999 | SENSOR_ATTR_TEMP_MAX_HYST(3), | 986 | |
1000 | SENSOR_ATTR_TEMP_MAX_HYST(4), | 987 | static struct attribute *vt1211_temp_attr[][5] = { |
1001 | SENSOR_ATTR_TEMP_MAX_HYST(5), | 988 | TEMP_UNIT_ATTRS(0), |
1002 | SENSOR_ATTR_TEMP_MAX_HYST(6), | 989 | TEMP_UNIT_ATTRS(1), |
1003 | SENSOR_ATTR_TEMP_MAX_HYST(7), | 990 | TEMP_UNIT_ATTRS(2), |
991 | TEMP_UNIT_ATTRS(3), | ||
992 | TEMP_UNIT_ATTRS(4), | ||
993 | TEMP_UNIT_ATTRS(5), | ||
994 | TEMP_UNIT_ATTRS(6) | ||
1004 | }; | 995 | }; |
1005 | 996 | ||
1006 | #define SENSOR_ATTR_TEMP_ALARM(ix) \ | 997 | static const struct attribute_group vt1211_temp_attr_group[] = { |
1007 | SENSOR_ATTR_2(temp##ix##_alarm, S_IRUGO, \ | 998 | { .attrs = vt1211_temp_attr[0] }, |
1008 | show_temp, NULL, SHOW_TEMP_ALARM, ix-1) | 999 | { .attrs = vt1211_temp_attr[1] }, |
1009 | 1000 | { .attrs = vt1211_temp_attr[2] }, | |
1010 | static struct sensor_device_attribute_2 vt1211_sysfs_temp_alarm[] = { | 1001 | { .attrs = vt1211_temp_attr[3] }, |
1011 | SENSOR_ATTR_TEMP_ALARM(1), | 1002 | { .attrs = vt1211_temp_attr[4] }, |
1012 | SENSOR_ATTR_TEMP_ALARM(2), | 1003 | { .attrs = vt1211_temp_attr[5] }, |
1013 | SENSOR_ATTR_TEMP_ALARM(3), | 1004 | { .attrs = vt1211_temp_attr[6] } |
1014 | SENSOR_ATTR_TEMP_ALARM(4), | ||
1015 | SENSOR_ATTR_TEMP_ALARM(5), | ||
1016 | SENSOR_ATTR_TEMP_ALARM(6), | ||
1017 | SENSOR_ATTR_TEMP_ALARM(7), | ||
1018 | }; | 1005 | }; |
1019 | 1006 | ||
1020 | #define SENSOR_ATTR_FAN(ix) \ | 1007 | #define SENSOR_ATTR_FAN(ix) \ |
@@ -1140,26 +1127,12 @@ static void vt1211_remove_sysfs(struct platform_device *pdev) | |||
1140 | struct device *dev = &pdev->dev; | 1127 | struct device *dev = &pdev->dev; |
1141 | int i; | 1128 | int i; |
1142 | 1129 | ||
1143 | for (i = 0; i < ARRAY_SIZE(vt1211_sysfs_in_input); i++) { | 1130 | for (i = 0; i < ARRAY_SIZE(vt1211_in_attr_group); i++) |
1144 | device_remove_file(dev, | 1131 | sysfs_remove_group(&dev->kobj, &vt1211_in_attr_group[i]); |
1145 | &vt1211_sysfs_in_input[i].dev_attr); | 1132 | |
1146 | device_remove_file(dev, | 1133 | for (i = 0; i < ARRAY_SIZE(vt1211_temp_attr_group); i++) |
1147 | &vt1211_sysfs_in_min[i].dev_attr); | 1134 | sysfs_remove_group(&dev->kobj, &vt1211_temp_attr_group[i]); |
1148 | device_remove_file(dev, | 1135 | |
1149 | &vt1211_sysfs_in_max[i].dev_attr); | ||
1150 | device_remove_file(dev, | ||
1151 | &vt1211_sysfs_in_alarm[i].dev_attr); | ||
1152 | } | ||
1153 | for (i = 0; i < ARRAY_SIZE(vt1211_sysfs_temp_input); i++) { | ||
1154 | device_remove_file(dev, | ||
1155 | &vt1211_sysfs_temp_input[i].dev_attr); | ||
1156 | device_remove_file(dev, | ||
1157 | &vt1211_sysfs_temp_max[i].dev_attr); | ||
1158 | device_remove_file(dev, | ||
1159 | &vt1211_sysfs_temp_max_hyst[i].dev_attr); | ||
1160 | device_remove_file(dev, | ||
1161 | &vt1211_sysfs_temp_alarm[i].dev_attr); | ||
1162 | } | ||
1163 | for (i = 0; i < ARRAY_SIZE(vt1211_sysfs_fan_pwm); i++) { | 1136 | for (i = 0; i < ARRAY_SIZE(vt1211_sysfs_fan_pwm); i++) { |
1164 | device_remove_file(dev, | 1137 | device_remove_file(dev, |
1165 | &vt1211_sysfs_fan_pwm[i].dev_attr); | 1138 | &vt1211_sysfs_fan_pwm[i].dev_attr); |
@@ -1199,32 +1172,20 @@ static int __devinit vt1211_probe(struct platform_device *pdev) | |||
1199 | vt1211_init_device(data); | 1172 | vt1211_init_device(data); |
1200 | 1173 | ||
1201 | /* Create sysfs interface files */ | 1174 | /* Create sysfs interface files */ |
1202 | for (i = 0; i < ARRAY_SIZE(vt1211_sysfs_in_input); i++) { | 1175 | for (i = 0; i < ARRAY_SIZE(vt1211_in_attr_group); i++) { |
1203 | if (ISVOLT(i, data->uch_config)) { | 1176 | if (ISVOLT(i, data->uch_config)) { |
1204 | if ((err = device_create_file(dev, | 1177 | err = sysfs_create_group(&dev->kobj, |
1205 | &vt1211_sysfs_in_input[i].dev_attr)) || | 1178 | &vt1211_in_attr_group[i]); |
1206 | (err = device_create_file(dev, | 1179 | if (err) |
1207 | &vt1211_sysfs_in_min[i].dev_attr)) || | ||
1208 | (err = device_create_file(dev, | ||
1209 | &vt1211_sysfs_in_max[i].dev_attr)) || | ||
1210 | (err = device_create_file(dev, | ||
1211 | &vt1211_sysfs_in_alarm[i].dev_attr))) { | ||
1212 | goto EXIT_DEV_REMOVE; | 1180 | goto EXIT_DEV_REMOVE; |
1213 | } | ||
1214 | } | 1181 | } |
1215 | } | 1182 | } |
1216 | for (i = 0; i < ARRAY_SIZE(vt1211_sysfs_temp_input); i++) { | 1183 | for (i = 0; i < ARRAY_SIZE(vt1211_temp_attr_group); i++) { |
1217 | if (ISTEMP(i, data->uch_config)) { | 1184 | if (ISTEMP(i, data->uch_config)) { |
1218 | if ((err = device_create_file(dev, | 1185 | err = sysfs_create_group(&dev->kobj, |
1219 | &vt1211_sysfs_temp_input[i].dev_attr)) || | 1186 | &vt1211_temp_attr_group[i]); |
1220 | (err = device_create_file(dev, | 1187 | if (err) |
1221 | &vt1211_sysfs_temp_max[i].dev_attr)) || | ||
1222 | (err = device_create_file(dev, | ||
1223 | &vt1211_sysfs_temp_max_hyst[i].dev_attr)) || | ||
1224 | (err = device_create_file(dev, | ||
1225 | &vt1211_sysfs_temp_alarm[i].dev_attr))) { | ||
1226 | goto EXIT_DEV_REMOVE; | 1188 | goto EXIT_DEV_REMOVE; |
1227 | } | ||
1228 | } | 1189 | } |
1229 | } | 1190 | } |
1230 | for (i = 0; i < ARRAY_SIZE(vt1211_sysfs_fan_pwm); i++) { | 1191 | for (i = 0; i < ARRAY_SIZE(vt1211_sysfs_fan_pwm); i++) { |