diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-01-15 10:03:38 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-18 21:26:45 -0400 |
commit | 65fe5c79577f181909a13500106027efd05db19a (patch) | |
tree | 0a9d1bc57b1942eab51be93dd27dd5313492a37c /drivers/hwmon/vt8231.c | |
parent | bafda5d0f5eeef6f80a9030b23d824fd16dcd827 (diff) |
hwmon: (vt8231) Fix checkpatch issues
Fixed:
ERROR: code indent should use tabs where possible
ERROR: do not use assignment in if condition
ERROR: trailing statements should be on next line
WARNING: braces {} are not necessary for any arm of this statement
WARNING: line over 80 characters
WARNING: please, no space before tabs
WARNING: simple_strtol is obsolete, use kstrtol instead
WARNING: simple_strtoul is obsolete, use kstrtoul instead
Not fixed (false positive):
ERROR: Macros with multiple statements should be enclosed in a do - while loop
Cc: Roger Lucas <vt8231@hiddenengine.co.uk>
Acked-by: Roger Lucas <vt8231@hiddenengine.co.uk>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/vt8231.c')
-rw-r--r-- | drivers/hwmon/vt8231.c | 127 |
1 files changed, 94 insertions, 33 deletions
diff --git a/drivers/hwmon/vt8231.c b/drivers/hwmon/vt8231.c index 11d6a39d2b9e..eb74f3778c90 100644 --- a/drivers/hwmon/vt8231.c +++ b/drivers/hwmon/vt8231.c | |||
@@ -56,12 +56,12 @@ static struct platform_device *pdev; | |||
56 | which sets the selected inputs marked with '*' below if multiple options are | 56 | which sets the selected inputs marked with '*' below if multiple options are |
57 | possible: | 57 | possible: |
58 | 58 | ||
59 | Voltage Mode Temperature Mode | 59 | Voltage Mode Temperature Mode |
60 | Sensor Linux Id Linux Id VIA Id | 60 | Sensor Linux Id Linux Id VIA Id |
61 | -------- -------- -------- ------ | 61 | -------- -------- -------- ------ |
62 | CPU Diode N/A temp1 0 | 62 | CPU Diode N/A temp1 0 |
63 | UIC1 in0 temp2 * 1 | 63 | UIC1 in0 temp2 * 1 |
64 | UIC2 in1 * temp3 2 | 64 | UIC2 in1 * temp3 2 |
65 | UIC3 in2 * temp4 3 | 65 | UIC3 in2 * temp4 3 |
66 | UIC4 in3 * temp5 4 | 66 | UIC4 in3 * temp5 4 |
67 | UIC5 in4 * temp6 5 | 67 | UIC5 in4 * temp6 5 |
@@ -222,7 +222,12 @@ static ssize_t set_in_min(struct device *dev, struct device_attribute *attr, | |||
222 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 222 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
223 | int nr = sensor_attr->index; | 223 | int nr = sensor_attr->index; |
224 | struct vt8231_data *data = dev_get_drvdata(dev); | 224 | struct vt8231_data *data = dev_get_drvdata(dev); |
225 | unsigned long val = simple_strtoul(buf, NULL, 10); | 225 | unsigned long val; |
226 | int err; | ||
227 | |||
228 | err = kstrtoul(buf, 10, &val); | ||
229 | if (err) | ||
230 | return err; | ||
226 | 231 | ||
227 | mutex_lock(&data->update_lock); | 232 | mutex_lock(&data->update_lock); |
228 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 233 | data->in_min[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
@@ -237,7 +242,12 @@ static ssize_t set_in_max(struct device *dev, struct device_attribute *attr, | |||
237 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 242 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
238 | int nr = sensor_attr->index; | 243 | int nr = sensor_attr->index; |
239 | struct vt8231_data *data = dev_get_drvdata(dev); | 244 | struct vt8231_data *data = dev_get_drvdata(dev); |
240 | unsigned long val = simple_strtoul(buf, NULL, 10); | 245 | unsigned long val; |
246 | int err; | ||
247 | |||
248 | err = kstrtoul(buf, 10, &val); | ||
249 | if (err) | ||
250 | return err; | ||
241 | 251 | ||
242 | mutex_lock(&data->update_lock); | 252 | mutex_lock(&data->update_lock); |
243 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); | 253 | data->in_max[nr] = SENSORS_LIMIT(((val * 958) / 10000) + 3, 0, 255); |
@@ -278,7 +288,12 @@ static ssize_t set_in5_min(struct device *dev, struct device_attribute *attr, | |||
278 | const char *buf, size_t count) | 288 | const char *buf, size_t count) |
279 | { | 289 | { |
280 | struct vt8231_data *data = dev_get_drvdata(dev); | 290 | struct vt8231_data *data = dev_get_drvdata(dev); |
281 | unsigned long val = simple_strtoul(buf, NULL, 10); | 291 | unsigned long val; |
292 | int err; | ||
293 | |||
294 | err = kstrtoul(buf, 10, &val); | ||
295 | if (err) | ||
296 | return err; | ||
282 | 297 | ||
283 | mutex_lock(&data->update_lock); | 298 | mutex_lock(&data->update_lock); |
284 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 299 | data->in_min[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
@@ -292,7 +307,12 @@ static ssize_t set_in5_max(struct device *dev, struct device_attribute *attr, | |||
292 | const char *buf, size_t count) | 307 | const char *buf, size_t count) |
293 | { | 308 | { |
294 | struct vt8231_data *data = dev_get_drvdata(dev); | 309 | struct vt8231_data *data = dev_get_drvdata(dev); |
295 | unsigned long val = simple_strtoul(buf, NULL, 10); | 310 | unsigned long val; |
311 | int err; | ||
312 | |||
313 | err = kstrtoul(buf, 10, &val); | ||
314 | if (err) | ||
315 | return err; | ||
296 | 316 | ||
297 | mutex_lock(&data->update_lock); | 317 | mutex_lock(&data->update_lock); |
298 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, | 318 | data->in_max[5] = SENSORS_LIMIT(((val * 958 * 34) / (10000 * 54)) + 3, |
@@ -346,7 +366,12 @@ static ssize_t set_temp0_max(struct device *dev, struct device_attribute *attr, | |||
346 | const char *buf, size_t count) | 366 | const char *buf, size_t count) |
347 | { | 367 | { |
348 | struct vt8231_data *data = dev_get_drvdata(dev); | 368 | struct vt8231_data *data = dev_get_drvdata(dev); |
349 | int val = simple_strtol(buf, NULL, 10); | 369 | long val; |
370 | int err; | ||
371 | |||
372 | err = kstrtol(buf, 10, &val); | ||
373 | if (err) | ||
374 | return err; | ||
350 | 375 | ||
351 | mutex_lock(&data->update_lock); | 376 | mutex_lock(&data->update_lock); |
352 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 377 | data->temp_max[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
@@ -358,7 +383,12 @@ static ssize_t set_temp0_min(struct device *dev, struct device_attribute *attr, | |||
358 | const char *buf, size_t count) | 383 | const char *buf, size_t count) |
359 | { | 384 | { |
360 | struct vt8231_data *data = dev_get_drvdata(dev); | 385 | struct vt8231_data *data = dev_get_drvdata(dev); |
361 | int val = simple_strtol(buf, NULL, 10); | 386 | long val; |
387 | int err; | ||
388 | |||
389 | err = kstrtol(buf, 10, &val); | ||
390 | if (err) | ||
391 | return err; | ||
362 | 392 | ||
363 | mutex_lock(&data->update_lock); | 393 | mutex_lock(&data->update_lock); |
364 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); | 394 | data->temp_min[0] = SENSORS_LIMIT((val + 500) / 1000, 0, 255); |
@@ -400,7 +430,12 @@ static ssize_t set_temp_max(struct device *dev, struct device_attribute *attr, | |||
400 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 430 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
401 | int nr = sensor_attr->index; | 431 | int nr = sensor_attr->index; |
402 | struct vt8231_data *data = dev_get_drvdata(dev); | 432 | struct vt8231_data *data = dev_get_drvdata(dev); |
403 | int val = simple_strtol(buf, NULL, 10); | 433 | long val; |
434 | int err; | ||
435 | |||
436 | err = kstrtol(buf, 10, &val); | ||
437 | if (err) | ||
438 | return err; | ||
404 | 439 | ||
405 | mutex_lock(&data->update_lock); | 440 | mutex_lock(&data->update_lock); |
406 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 441 | data->temp_max[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
@@ -414,7 +449,12 @@ static ssize_t set_temp_min(struct device *dev, struct device_attribute *attr, | |||
414 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 449 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
415 | int nr = sensor_attr->index; | 450 | int nr = sensor_attr->index; |
416 | struct vt8231_data *data = dev_get_drvdata(dev); | 451 | struct vt8231_data *data = dev_get_drvdata(dev); |
417 | int val = simple_strtol(buf, NULL, 10); | 452 | long val; |
453 | int err; | ||
454 | |||
455 | err = kstrtol(buf, 10, &val); | ||
456 | if (err) | ||
457 | return err; | ||
418 | 458 | ||
419 | mutex_lock(&data->update_lock); | 459 | mutex_lock(&data->update_lock); |
420 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); | 460 | data->temp_min[nr] = SENSORS_LIMIT(TEMP_MAXMIN_TO_REG(val), 0, 255); |
@@ -436,7 +476,8 @@ static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \ | |||
436 | 476 | ||
437 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp0, NULL); | 477 | static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp0, NULL); |
438 | static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp0_max, set_temp0_max); | 478 | static DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp0_max, set_temp0_max); |
439 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp0_min, set_temp0_min); | 479 | static DEVICE_ATTR(temp1_max_hyst, S_IRUGO | S_IWUSR, show_temp0_min, |
480 | set_temp0_min); | ||
440 | 481 | ||
441 | define_temperature_sysfs(2); | 482 | define_temperature_sysfs(2); |
442 | define_temperature_sysfs(3); | 483 | define_temperature_sysfs(3); |
@@ -480,7 +521,12 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr, | |||
480 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 521 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
481 | int nr = sensor_attr->index; | 522 | int nr = sensor_attr->index; |
482 | struct vt8231_data *data = dev_get_drvdata(dev); | 523 | struct vt8231_data *data = dev_get_drvdata(dev); |
483 | int val = simple_strtoul(buf, NULL, 10); | 524 | unsigned long val; |
525 | int err; | ||
526 | |||
527 | err = kstrtoul(buf, 10, &val); | ||
528 | if (err) | ||
529 | return err; | ||
484 | 530 | ||
485 | mutex_lock(&data->update_lock); | 531 | mutex_lock(&data->update_lock); |
486 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); | 532 | data->fan_min[nr] = FAN_TO_REG(val, DIV_FROM_REG(data->fan_div[nr])); |
@@ -494,21 +540,34 @@ static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr, | |||
494 | { | 540 | { |
495 | struct vt8231_data *data = dev_get_drvdata(dev); | 541 | struct vt8231_data *data = dev_get_drvdata(dev); |
496 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); | 542 | struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); |
497 | unsigned long val = simple_strtoul(buf, NULL, 10); | 543 | unsigned long val; |
498 | int nr = sensor_attr->index; | 544 | int nr = sensor_attr->index; |
499 | int old = vt8231_read_value(data, VT8231_REG_FANDIV); | 545 | int old = vt8231_read_value(data, VT8231_REG_FANDIV); |
500 | long min = FAN_FROM_REG(data->fan_min[nr], | 546 | long min = FAN_FROM_REG(data->fan_min[nr], |
501 | DIV_FROM_REG(data->fan_div[nr])); | 547 | DIV_FROM_REG(data->fan_div[nr])); |
548 | int err; | ||
549 | |||
550 | err = kstrtoul(buf, 10, &val); | ||
551 | if (err) | ||
552 | return err; | ||
502 | 553 | ||
503 | mutex_lock(&data->update_lock); | 554 | mutex_lock(&data->update_lock); |
504 | switch (val) { | 555 | switch (val) { |
505 | case 1: data->fan_div[nr] = 0; break; | 556 | case 1: |
506 | case 2: data->fan_div[nr] = 1; break; | 557 | data->fan_div[nr] = 0; |
507 | case 4: data->fan_div[nr] = 2; break; | 558 | break; |
508 | case 8: data->fan_div[nr] = 3; break; | 559 | case 2: |
560 | data->fan_div[nr] = 1; | ||
561 | break; | ||
562 | case 4: | ||
563 | data->fan_div[nr] = 2; | ||
564 | break; | ||
565 | case 8: | ||
566 | data->fan_div[nr] = 3; | ||
567 | break; | ||
509 | default: | 568 | default: |
510 | dev_err(dev, "fan_div value %ld not supported. " | 569 | dev_err(dev, "fan_div value %ld not supported. " |
511 | "Choose one of 1, 2, 4 or 8!\n", val); | 570 | "Choose one of 1, 2, 4 or 8!\n", val); |
512 | mutex_unlock(&data->update_lock); | 571 | mutex_unlock(&data->update_lock); |
513 | return -EINVAL; | 572 | return -EINVAL; |
514 | } | 573 | } |
@@ -707,7 +766,7 @@ static DEFINE_PCI_DEVICE_TABLE(vt8231_pci_ids) = { | |||
707 | MODULE_DEVICE_TABLE(pci, vt8231_pci_ids); | 766 | MODULE_DEVICE_TABLE(pci, vt8231_pci_ids); |
708 | 767 | ||
709 | static int __devinit vt8231_pci_probe(struct pci_dev *dev, | 768 | static int __devinit vt8231_pci_probe(struct pci_dev *dev, |
710 | const struct pci_device_id *id); | 769 | const struct pci_device_id *id); |
711 | 770 | ||
712 | static struct pci_driver vt8231_pci_driver = { | 771 | static struct pci_driver vt8231_pci_driver = { |
713 | .name = "vt8231", | 772 | .name = "vt8231", |
@@ -730,7 +789,8 @@ static int vt8231_probe(struct platform_device *pdev) | |||
730 | return -ENODEV; | 789 | return -ENODEV; |
731 | } | 790 | } |
732 | 791 | ||
733 | if (!(data = kzalloc(sizeof(struct vt8231_data), GFP_KERNEL))) { | 792 | data = kzalloc(sizeof(struct vt8231_data), GFP_KERNEL); |
793 | if (!data) { | ||
734 | err = -ENOMEM; | 794 | err = -ENOMEM; |
735 | goto exit_release; | 795 | goto exit_release; |
736 | } | 796 | } |
@@ -743,7 +803,8 @@ static int vt8231_probe(struct platform_device *pdev) | |||
743 | vt8231_init_device(data); | 803 | vt8231_init_device(data); |
744 | 804 | ||
745 | /* Register sysfs hooks */ | 805 | /* Register sysfs hooks */ |
746 | if ((err = sysfs_create_group(&pdev->dev.kobj, &vt8231_group))) | 806 | err = sysfs_create_group(&pdev->dev.kobj, &vt8231_group); |
807 | if (err) | ||
747 | goto exit_free; | 808 | goto exit_free; |
748 | 809 | ||
749 | /* Must update device information to find out the config field */ | 810 | /* Must update device information to find out the config field */ |
@@ -751,16 +812,18 @@ static int vt8231_probe(struct platform_device *pdev) | |||
751 | 812 | ||
752 | for (i = 0; i < ARRAY_SIZE(vt8231_group_temps); i++) { | 813 | for (i = 0; i < ARRAY_SIZE(vt8231_group_temps); i++) { |
753 | if (ISTEMP(i, data->uch_config)) { | 814 | if (ISTEMP(i, data->uch_config)) { |
754 | if ((err = sysfs_create_group(&pdev->dev.kobj, | 815 | err = sysfs_create_group(&pdev->dev.kobj, |
755 | &vt8231_group_temps[i]))) | 816 | &vt8231_group_temps[i]); |
817 | if (err) | ||
756 | goto exit_remove_files; | 818 | goto exit_remove_files; |
757 | } | 819 | } |
758 | } | 820 | } |
759 | 821 | ||
760 | for (i = 0; i < ARRAY_SIZE(vt8231_group_volts); i++) { | 822 | for (i = 0; i < ARRAY_SIZE(vt8231_group_volts); i++) { |
761 | if (ISVOLT(i, data->uch_config)) { | 823 | if (ISVOLT(i, data->uch_config)) { |
762 | if ((err = sysfs_create_group(&pdev->dev.kobj, | 824 | err = sysfs_create_group(&pdev->dev.kobj, |
763 | &vt8231_group_volts[i]))) | 825 | &vt8231_group_volts[i]); |
826 | if (err) | ||
764 | goto exit_remove_files; | 827 | goto exit_remove_files; |
765 | } | 828 | } |
766 | } | 829 | } |
@@ -866,17 +929,15 @@ static struct vt8231_data *vt8231_update_device(struct device *dev) | |||
866 | (vt8231_read_value(data, VT8231_REG_ALARM2) << 8); | 929 | (vt8231_read_value(data, VT8231_REG_ALARM2) << 8); |
867 | 930 | ||
868 | /* Set alarm flags correctly */ | 931 | /* Set alarm flags correctly */ |
869 | if (!data->fan[0] && data->fan_min[0]) { | 932 | if (!data->fan[0] && data->fan_min[0]) |
870 | data->alarms |= 0x40; | 933 | data->alarms |= 0x40; |
871 | } else if (data->fan[0] && !data->fan_min[0]) { | 934 | else if (data->fan[0] && !data->fan_min[0]) |
872 | data->alarms &= ~0x40; | 935 | data->alarms &= ~0x40; |
873 | } | ||
874 | 936 | ||
875 | if (!data->fan[1] && data->fan_min[1]) { | 937 | if (!data->fan[1] && data->fan_min[1]) |
876 | data->alarms |= 0x80; | 938 | data->alarms |= 0x80; |
877 | } else if (data->fan[1] && !data->fan_min[1]) { | 939 | else if (data->fan[1] && !data->fan_min[1]) |
878 | data->alarms &= ~0x80; | 940 | data->alarms &= ~0x80; |
879 | } | ||
880 | 941 | ||
881 | data->last_updated = jiffies; | 942 | data->last_updated = jiffies; |
882 | data->valid = 1; | 943 | data->valid = 1; |