aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pc87360.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2012-01-19 23:50:57 -0500
committerGuenter Roeck <guenter.roeck@ericsson.com>2012-03-18 21:27:27 -0400
commitbce2778df9ea32146d59344c027001e270911f4b (patch)
tree0eeeb27ff65665943631c82b9aa6391728cef41f /drivers/hwmon/pc87360.c
parent449a7a0720f2edc84288fb239bca8b2f9366881d (diff)
hwmon: (pc87360) 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> Cc: Jim Cromie <jim.cromie@gmail.com> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/pc87360.c')
-rw-r--r--drivers/hwmon/pc87360.c129
1 files changed, 58 insertions, 71 deletions
diff --git a/drivers/hwmon/pc87360.c b/drivers/hwmon/pc87360.c
index 000499ea5973..79ba48c8c116 100644
--- a/drivers/hwmon/pc87360.c
+++ b/drivers/hwmon/pc87360.c
@@ -346,11 +346,13 @@ static struct sensor_device_attribute fan_min[] = {
346 SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2), 346 SENSOR_ATTR(fan3_min, S_IWUSR | S_IRUGO, show_fan_min, set_fan_min, 2),
347}; 347};
348 348
349#define FAN_UNIT_ATTRS(X) \ 349#define FAN_UNIT_ATTRS(X) \
350 &fan_input[X].dev_attr.attr, \ 350{ &fan_input[X].dev_attr.attr, \
351 &fan_status[X].dev_attr.attr, \ 351 &fan_status[X].dev_attr.attr, \
352 &fan_div[X].dev_attr.attr, \ 352 &fan_div[X].dev_attr.attr, \
353 &fan_min[X].dev_attr.attr 353 &fan_min[X].dev_attr.attr, \
354 NULL \
355}
354 356
355static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr, 357static ssize_t show_pwm(struct device *dev, struct device_attribute *devattr,
356 char *buf) 358 char *buf)
@@ -389,17 +391,16 @@ static struct sensor_device_attribute pwm[] = {
389 SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2), 391 SENSOR_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2),
390}; 392};
391 393
392static struct attribute *pc8736x_fan_attr_array[] = { 394static struct attribute *pc8736x_fan_attr[][5] = {
393 FAN_UNIT_ATTRS(0), 395 FAN_UNIT_ATTRS(0),
394 FAN_UNIT_ATTRS(1), 396 FAN_UNIT_ATTRS(1),
395 FAN_UNIT_ATTRS(2), 397 FAN_UNIT_ATTRS(2)
396 &pwm[0].dev_attr.attr,
397 &pwm[1].dev_attr.attr,
398 &pwm[2].dev_attr.attr,
399 NULL
400}; 398};
401static const struct attribute_group pc8736x_fan_group = { 399
402 .attrs = pc8736x_fan_attr_array, 400static const struct attribute_group pc8736x_fan_attr_group[] = {
401 { .attrs = pc8736x_fan_attr[0], },
402 { .attrs = pc8736x_fan_attr[1], },
403 { .attrs = pc8736x_fan_attr[2], },
403}; 404};
404 405
405static ssize_t show_in_input(struct device *dev, 406static ssize_t show_in_input(struct device *dev,
@@ -1078,28 +1079,29 @@ static struct sensor_device_attribute temp_fault[] = {
1078 SENSOR_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2), 1079 SENSOR_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2),
1079}; 1080};
1080 1081
1081#define TEMP_UNIT_ATTRS(X) \ 1082#define TEMP_UNIT_ATTRS(X) \
1082 &temp_input[X].dev_attr.attr, \ 1083{ &temp_input[X].dev_attr.attr, \
1083 &temp_status[X].dev_attr.attr, \ 1084 &temp_status[X].dev_attr.attr, \
1084 &temp_min[X].dev_attr.attr, \ 1085 &temp_min[X].dev_attr.attr, \
1085 &temp_max[X].dev_attr.attr, \ 1086 &temp_max[X].dev_attr.attr, \
1086 &temp_crit[X].dev_attr.attr, \ 1087 &temp_crit[X].dev_attr.attr, \
1087 &temp_min_alarm[X].dev_attr.attr, \ 1088 &temp_min_alarm[X].dev_attr.attr, \
1088 &temp_max_alarm[X].dev_attr.attr, \ 1089 &temp_max_alarm[X].dev_attr.attr, \
1089 &temp_crit_alarm[X].dev_attr.attr, \ 1090 &temp_crit_alarm[X].dev_attr.attr, \
1090 &temp_fault[X].dev_attr.attr 1091 &temp_fault[X].dev_attr.attr, \
1091 1092 NULL \
1092static struct attribute *pc8736x_temp_attr_array[] = { 1093}
1094
1095static struct attribute *pc8736x_temp_attr[][10] = {
1093 TEMP_UNIT_ATTRS(0), 1096 TEMP_UNIT_ATTRS(0),
1094 TEMP_UNIT_ATTRS(1), 1097 TEMP_UNIT_ATTRS(1),
1095 TEMP_UNIT_ATTRS(2), 1098 TEMP_UNIT_ATTRS(2)
1096 /* include the few miscellaneous atts here */
1097 &dev_attr_alarms_temp.attr,
1098 NULL
1099}; 1099};
1100 1100
1101static const struct attribute_group pc8736x_temp_group = { 1101static const struct attribute_group pc8736x_temp_attr_group[] = {
1102 .attrs = pc8736x_temp_attr_array, 1102 { .attrs = pc8736x_temp_attr[0] },
1103 { .attrs = pc8736x_temp_attr[1] },
1104 { .attrs = pc8736x_temp_attr[2] }
1103}; 1105};
1104 1106
1105static ssize_t show_name(struct device *dev, 1107static ssize_t show_name(struct device *dev,
@@ -1203,6 +1205,22 @@ static int __init pc87360_find(int sioaddr, u8 *devid,
1203 return 0; 1205 return 0;
1204} 1206}
1205 1207
1208static void pc87360_remove_files(struct device *dev)
1209{
1210 int i;
1211
1212 device_remove_file(dev, &dev_attr_name);
1213 device_remove_file(dev, &dev_attr_alarms_temp);
1214 for (i = 0; i < ARRAY_SIZE(pc8736x_temp_attr_group); i++)
1215 sysfs_remove_group(&dev->kobj, &pc8736x_temp_attr_group[i]);
1216 for (i = 0; i < ARRAY_SIZE(pc8736x_fan_attr_group); i++) {
1217 sysfs_remove_group(&pdev->dev.kobj, &pc8736x_fan_attr_group[i]);
1218 device_remove_file(dev, &pwm[i].dev_attr);
1219 }
1220 sysfs_remove_group(&dev->kobj, &pc8736x_therm_group);
1221 sysfs_remove_group(&dev->kobj, &pc8736x_vin_group);
1222}
1223
1206static int __devinit pc87360_probe(struct platform_device *pdev) 1224static int __devinit pc87360_probe(struct platform_device *pdev)
1207{ 1225{
1208 int i; 1226 int i;
@@ -1320,24 +1338,9 @@ static int __devinit pc87360_probe(struct platform_device *pdev)
1320 1338
1321 if (data->tempnr) { 1339 if (data->tempnr) {
1322 for (i = 0; i < data->tempnr; i++) { 1340 for (i = 0; i < data->tempnr; i++) {
1323 if ((err = device_create_file(dev, 1341 err = sysfs_create_group(&dev->kobj,
1324 &temp_input[i].dev_attr)) 1342 &pc8736x_temp_attr_group[i]);
1325 || (err = device_create_file(dev, 1343 if (err)
1326 &temp_min[i].dev_attr))
1327 || (err = device_create_file(dev,
1328 &temp_max[i].dev_attr))
1329 || (err = device_create_file(dev,
1330 &temp_crit[i].dev_attr))
1331 || (err = device_create_file(dev,
1332 &temp_status[i].dev_attr))
1333 || (err = device_create_file(dev,
1334 &temp_min_alarm[i].dev_attr))
1335 || (err = device_create_file(dev,
1336 &temp_max_alarm[i].dev_attr))
1337 || (err = device_create_file(dev,
1338 &temp_crit_alarm[i].dev_attr))
1339 || (err = device_create_file(dev,
1340 &temp_fault[i].dev_attr)))
1341 goto ERROR3; 1344 goto ERROR3;
1342 } 1345 }
1343 err = device_create_file(dev, &dev_attr_alarms_temp); 1346 err = device_create_file(dev, &dev_attr_alarms_temp);
@@ -1346,17 +1349,12 @@ static int __devinit pc87360_probe(struct platform_device *pdev)
1346 } 1349 }
1347 1350
1348 for (i = 0; i < data->fannr; i++) { 1351 for (i = 0; i < data->fannr; i++) {
1349 if (FAN_CONFIG_MONITOR(data->fan_conf, i) 1352 if (FAN_CONFIG_MONITOR(data->fan_conf, i)) {
1350 && ((err = device_create_file(dev, 1353 err = sysfs_create_group(&dev->kobj,
1351 &fan_input[i].dev_attr)) 1354 &pc8736x_fan_attr_group[i]);
1352 || (err = device_create_file(dev, 1355 if (err)
1353 &fan_min[i].dev_attr)) 1356 goto ERROR3;
1354 || (err = device_create_file(dev, 1357 }
1355 &fan_div[i].dev_attr))
1356 || (err = device_create_file(dev,
1357 &fan_status[i].dev_attr))))
1358 goto ERROR3;
1359
1360 if (FAN_CONFIG_CONTROL(data->fan_conf, i)) { 1358 if (FAN_CONFIG_CONTROL(data->fan_conf, i)) {
1361 err = device_create_file(dev, &pwm[i].dev_attr); 1359 err = device_create_file(dev, &pwm[i].dev_attr);
1362 if (err) 1360 if (err)
@@ -1376,12 +1374,7 @@ static int __devinit pc87360_probe(struct platform_device *pdev)
1376 return 0; 1374 return 0;
1377 1375
1378ERROR3: 1376ERROR3:
1379 device_remove_file(dev, &dev_attr_name); 1377 pc87360_remove_files(dev);
1380 /* can still remove groups whose members were added individually */
1381 sysfs_remove_group(&dev->kobj, &pc8736x_temp_group);
1382 sysfs_remove_group(&dev->kobj, &pc8736x_fan_group);
1383 sysfs_remove_group(&dev->kobj, &pc8736x_therm_group);
1384 sysfs_remove_group(&dev->kobj, &pc8736x_vin_group);
1385 for (i = 0; i < 3; i++) { 1378 for (i = 0; i < 3; i++) {
1386 if (data->address[i]) 1379 if (data->address[i])
1387 release_region(data->address[i], PC87360_EXTENT); 1380 release_region(data->address[i], PC87360_EXTENT);
@@ -1397,13 +1390,7 @@ static int __devexit pc87360_remove(struct platform_device *pdev)
1397 int i; 1390 int i;
1398 1391
1399 hwmon_device_unregister(data->hwmon_dev); 1392 hwmon_device_unregister(data->hwmon_dev);
1400 1393 pc87360_remove_files(&pdev->dev);
1401 device_remove_file(&pdev->dev, &dev_attr_name);
1402 sysfs_remove_group(&pdev->dev.kobj, &pc8736x_temp_group);
1403 sysfs_remove_group(&pdev->dev.kobj, &pc8736x_fan_group);
1404 sysfs_remove_group(&pdev->dev.kobj, &pc8736x_therm_group);
1405 sysfs_remove_group(&pdev->dev.kobj, &pc8736x_vin_group);
1406
1407 for (i = 0; i < 3; i++) { 1394 for (i = 0; i < 3; i++) {
1408 if (data->address[i]) 1395 if (data->address[i])
1409 release_region(data->address[i], PC87360_EXTENT); 1396 release_region(data->address[i], PC87360_EXTENT);