diff options
author | Guenter Roeck <linux@roeck-us.net> | 2012-01-16 20:15:02 -0500 |
---|---|---|
committer | Guenter Roeck <guenter.roeck@ericsson.com> | 2012-03-18 21:27:08 -0400 |
commit | 7e612685a3a3f0c1159f4562421e91a6c55d024e (patch) | |
tree | 42f20b9296cad8346e5005a18ce17329254cde11 /drivers/hwmon/smsc47m1.c | |
parent | 7cc3cb6662a21a59a2e0e752a8ebd95137c71d3a (diff) |
hwmon: (smsc47m1) 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>
Diffstat (limited to 'drivers/hwmon/smsc47m1.c')
-rw-r--r-- | drivers/hwmon/smsc47m1.c | 125 |
1 files changed, 80 insertions, 45 deletions
diff --git a/drivers/hwmon/smsc47m1.c b/drivers/hwmon/smsc47m1.c index f44a89aac381..aba11e56e8e7 100644 --- a/drivers/hwmon/smsc47m1.c +++ b/drivers/hwmon/smsc47m1.c | |||
@@ -380,30 +380,73 @@ static ssize_t show_name(struct device *dev, struct device_attribute | |||
380 | } | 380 | } |
381 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); | 381 | static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); |
382 | 382 | ||
383 | /* Almost all sysfs files may or may not be created depending on the chip | 383 | static struct attribute *smsc47m1_attributes_fan1[] = { |
384 | setup so we create them individually. It is still convenient to define a | ||
385 | group to remove them all at once. */ | ||
386 | static struct attribute *smsc47m1_attributes[] = { | ||
387 | &sensor_dev_attr_fan1_input.dev_attr.attr, | 384 | &sensor_dev_attr_fan1_input.dev_attr.attr, |
388 | &sensor_dev_attr_fan1_min.dev_attr.attr, | 385 | &sensor_dev_attr_fan1_min.dev_attr.attr, |
389 | &sensor_dev_attr_fan1_div.dev_attr.attr, | 386 | &sensor_dev_attr_fan1_div.dev_attr.attr, |
390 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, | 387 | &sensor_dev_attr_fan1_alarm.dev_attr.attr, |
388 | NULL | ||
389 | }; | ||
390 | |||
391 | static const struct attribute_group smsc47m1_group_fan1 = { | ||
392 | .attrs = smsc47m1_attributes_fan1, | ||
393 | }; | ||
394 | |||
395 | static struct attribute *smsc47m1_attributes_fan2[] = { | ||
391 | &sensor_dev_attr_fan2_input.dev_attr.attr, | 396 | &sensor_dev_attr_fan2_input.dev_attr.attr, |
392 | &sensor_dev_attr_fan2_min.dev_attr.attr, | 397 | &sensor_dev_attr_fan2_min.dev_attr.attr, |
393 | &sensor_dev_attr_fan2_div.dev_attr.attr, | 398 | &sensor_dev_attr_fan2_div.dev_attr.attr, |
394 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, | 399 | &sensor_dev_attr_fan2_alarm.dev_attr.attr, |
400 | NULL | ||
401 | }; | ||
402 | |||
403 | static const struct attribute_group smsc47m1_group_fan2 = { | ||
404 | .attrs = smsc47m1_attributes_fan2, | ||
405 | }; | ||
406 | |||
407 | static struct attribute *smsc47m1_attributes_fan3[] = { | ||
395 | &sensor_dev_attr_fan3_input.dev_attr.attr, | 408 | &sensor_dev_attr_fan3_input.dev_attr.attr, |
396 | &sensor_dev_attr_fan3_min.dev_attr.attr, | 409 | &sensor_dev_attr_fan3_min.dev_attr.attr, |
397 | &sensor_dev_attr_fan3_div.dev_attr.attr, | 410 | &sensor_dev_attr_fan3_div.dev_attr.attr, |
398 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, | 411 | &sensor_dev_attr_fan3_alarm.dev_attr.attr, |
412 | NULL | ||
413 | }; | ||
414 | |||
415 | static const struct attribute_group smsc47m1_group_fan3 = { | ||
416 | .attrs = smsc47m1_attributes_fan3, | ||
417 | }; | ||
399 | 418 | ||
419 | static struct attribute *smsc47m1_attributes_pwm1[] = { | ||
400 | &sensor_dev_attr_pwm1.dev_attr.attr, | 420 | &sensor_dev_attr_pwm1.dev_attr.attr, |
401 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, | 421 | &sensor_dev_attr_pwm1_enable.dev_attr.attr, |
422 | NULL | ||
423 | }; | ||
424 | |||
425 | static const struct attribute_group smsc47m1_group_pwm1 = { | ||
426 | .attrs = smsc47m1_attributes_pwm1, | ||
427 | }; | ||
428 | |||
429 | static struct attribute *smsc47m1_attributes_pwm2[] = { | ||
402 | &sensor_dev_attr_pwm2.dev_attr.attr, | 430 | &sensor_dev_attr_pwm2.dev_attr.attr, |
403 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, | 431 | &sensor_dev_attr_pwm2_enable.dev_attr.attr, |
432 | NULL | ||
433 | }; | ||
434 | |||
435 | static const struct attribute_group smsc47m1_group_pwm2 = { | ||
436 | .attrs = smsc47m1_attributes_pwm2, | ||
437 | }; | ||
438 | |||
439 | static struct attribute *smsc47m1_attributes_pwm3[] = { | ||
404 | &sensor_dev_attr_pwm3.dev_attr.attr, | 440 | &sensor_dev_attr_pwm3.dev_attr.attr, |
405 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, | 441 | &sensor_dev_attr_pwm3_enable.dev_attr.attr, |
442 | NULL | ||
443 | }; | ||
444 | |||
445 | static const struct attribute_group smsc47m1_group_pwm3 = { | ||
446 | .attrs = smsc47m1_attributes_pwm3, | ||
447 | }; | ||
406 | 448 | ||
449 | static struct attribute *smsc47m1_attributes[] = { | ||
407 | &dev_attr_alarms.attr, | 450 | &dev_attr_alarms.attr, |
408 | &dev_attr_name.attr, | 451 | &dev_attr_name.attr, |
409 | NULL | 452 | NULL |
@@ -583,6 +626,17 @@ static int smsc47m1_handle_resources(unsigned short address, enum chips type, | |||
583 | return 0; | 626 | return 0; |
584 | } | 627 | } |
585 | 628 | ||
629 | static void smsc47m1_remove_files(struct device *dev) | ||
630 | { | ||
631 | sysfs_remove_group(&dev->kobj, &smsc47m1_group); | ||
632 | sysfs_remove_group(&dev->kobj, &smsc47m1_group_fan1); | ||
633 | sysfs_remove_group(&dev->kobj, &smsc47m1_group_fan2); | ||
634 | sysfs_remove_group(&dev->kobj, &smsc47m1_group_fan3); | ||
635 | sysfs_remove_group(&dev->kobj, &smsc47m1_group_pwm1); | ||
636 | sysfs_remove_group(&dev->kobj, &smsc47m1_group_pwm2); | ||
637 | sysfs_remove_group(&dev->kobj, &smsc47m1_group_pwm3); | ||
638 | } | ||
639 | |||
586 | static int __init smsc47m1_probe(struct platform_device *pdev) | 640 | static int __init smsc47m1_probe(struct platform_device *pdev) |
587 | { | 641 | { |
588 | struct device *dev = &pdev->dev; | 642 | struct device *dev = &pdev->dev; |
@@ -653,74 +707,55 @@ static int __init smsc47m1_probe(struct platform_device *pdev) | |||
653 | 707 | ||
654 | /* Register sysfs hooks */ | 708 | /* Register sysfs hooks */ |
655 | if (fan1) { | 709 | if (fan1) { |
656 | if ((err = device_create_file(dev, | 710 | err = sysfs_create_group(&dev->kobj, |
657 | &sensor_dev_attr_fan1_input.dev_attr)) | 711 | &smsc47m1_group_fan1); |
658 | || (err = device_create_file(dev, | 712 | if (err) |
659 | &sensor_dev_attr_fan1_min.dev_attr)) | ||
660 | || (err = device_create_file(dev, | ||
661 | &sensor_dev_attr_fan1_div.dev_attr)) | ||
662 | || (err = device_create_file(dev, | ||
663 | &sensor_dev_attr_fan1_alarm.dev_attr))) | ||
664 | goto error_remove_files; | 713 | goto error_remove_files; |
665 | } else | 714 | } else |
666 | dev_dbg(dev, "Fan 1 not enabled by hardware, skipping\n"); | 715 | dev_dbg(dev, "Fan 1 not enabled by hardware, skipping\n"); |
667 | 716 | ||
668 | if (fan2) { | 717 | if (fan2) { |
669 | if ((err = device_create_file(dev, | 718 | err = sysfs_create_group(&dev->kobj, |
670 | &sensor_dev_attr_fan2_input.dev_attr)) | 719 | &smsc47m1_group_fan2); |
671 | || (err = device_create_file(dev, | 720 | if (err) |
672 | &sensor_dev_attr_fan2_min.dev_attr)) | ||
673 | || (err = device_create_file(dev, | ||
674 | &sensor_dev_attr_fan2_div.dev_attr)) | ||
675 | || (err = device_create_file(dev, | ||
676 | &sensor_dev_attr_fan2_alarm.dev_attr))) | ||
677 | goto error_remove_files; | 721 | goto error_remove_files; |
678 | } else | 722 | } else |
679 | dev_dbg(dev, "Fan 2 not enabled by hardware, skipping\n"); | 723 | dev_dbg(dev, "Fan 2 not enabled by hardware, skipping\n"); |
680 | 724 | ||
681 | if (fan3) { | 725 | if (fan3) { |
682 | if ((err = device_create_file(dev, | 726 | err = sysfs_create_group(&dev->kobj, |
683 | &sensor_dev_attr_fan3_input.dev_attr)) | 727 | &smsc47m1_group_fan3); |
684 | || (err = device_create_file(dev, | 728 | if (err) |
685 | &sensor_dev_attr_fan3_min.dev_attr)) | ||
686 | || (err = device_create_file(dev, | ||
687 | &sensor_dev_attr_fan3_div.dev_attr)) | ||
688 | || (err = device_create_file(dev, | ||
689 | &sensor_dev_attr_fan3_alarm.dev_attr))) | ||
690 | goto error_remove_files; | 729 | goto error_remove_files; |
691 | } else if (data->type == smsc47m2) | 730 | } else if (data->type == smsc47m2) |
692 | dev_dbg(dev, "Fan 3 not enabled by hardware, skipping\n"); | 731 | dev_dbg(dev, "Fan 3 not enabled by hardware, skipping\n"); |
693 | 732 | ||
694 | if (pwm1) { | 733 | if (pwm1) { |
695 | if ((err = device_create_file(dev, | 734 | err = sysfs_create_group(&dev->kobj, |
696 | &sensor_dev_attr_pwm1.dev_attr)) | 735 | &smsc47m1_group_pwm1); |
697 | || (err = device_create_file(dev, | 736 | if (err) |
698 | &sensor_dev_attr_pwm1_enable.dev_attr))) | ||
699 | goto error_remove_files; | 737 | goto error_remove_files; |
700 | } else | 738 | } else |
701 | dev_dbg(dev, "PWM 1 not enabled by hardware, skipping\n"); | 739 | dev_dbg(dev, "PWM 1 not enabled by hardware, skipping\n"); |
702 | 740 | ||
703 | if (pwm2) { | 741 | if (pwm2) { |
704 | if ((err = device_create_file(dev, | 742 | err = sysfs_create_group(&dev->kobj, |
705 | &sensor_dev_attr_pwm2.dev_attr)) | 743 | &smsc47m1_group_pwm2); |
706 | || (err = device_create_file(dev, | 744 | if (err) |
707 | &sensor_dev_attr_pwm2_enable.dev_attr))) | ||
708 | goto error_remove_files; | 745 | goto error_remove_files; |
709 | } else | 746 | } else |
710 | dev_dbg(dev, "PWM 2 not enabled by hardware, skipping\n"); | 747 | dev_dbg(dev, "PWM 2 not enabled by hardware, skipping\n"); |
711 | 748 | ||
712 | if (pwm3) { | 749 | if (pwm3) { |
713 | if ((err = device_create_file(dev, | 750 | err = sysfs_create_group(&dev->kobj, |
714 | &sensor_dev_attr_pwm3.dev_attr)) | 751 | &smsc47m1_group_pwm3); |
715 | || (err = device_create_file(dev, | 752 | if (err) |
716 | &sensor_dev_attr_pwm3_enable.dev_attr))) | ||
717 | goto error_remove_files; | 753 | goto error_remove_files; |
718 | } else if (data->type == smsc47m2) | 754 | } else if (data->type == smsc47m2) |
719 | dev_dbg(dev, "PWM 3 not enabled by hardware, skipping\n"); | 755 | dev_dbg(dev, "PWM 3 not enabled by hardware, skipping\n"); |
720 | 756 | ||
721 | if ((err = device_create_file(dev, &dev_attr_alarms))) | 757 | err = sysfs_create_group(&dev->kobj, &smsc47m1_group); |
722 | goto error_remove_files; | 758 | if (err) |
723 | if ((err = device_create_file(dev, &dev_attr_name))) | ||
724 | goto error_remove_files; | 759 | goto error_remove_files; |
725 | 760 | ||
726 | data->hwmon_dev = hwmon_device_register(dev); | 761 | data->hwmon_dev = hwmon_device_register(dev); |
@@ -732,7 +767,7 @@ static int __init smsc47m1_probe(struct platform_device *pdev) | |||
732 | return 0; | 767 | return 0; |
733 | 768 | ||
734 | error_remove_files: | 769 | error_remove_files: |
735 | sysfs_remove_group(&dev->kobj, &smsc47m1_group); | 770 | smsc47m1_remove_files(dev); |
736 | error_free: | 771 | error_free: |
737 | platform_set_drvdata(pdev, NULL); | 772 | platform_set_drvdata(pdev, NULL); |
738 | kfree(data); | 773 | kfree(data); |
@@ -747,7 +782,7 @@ static int __exit smsc47m1_remove(struct platform_device *pdev) | |||
747 | struct resource *res; | 782 | struct resource *res; |
748 | 783 | ||
749 | hwmon_device_unregister(data->hwmon_dev); | 784 | hwmon_device_unregister(data->hwmon_dev); |
750 | sysfs_remove_group(&pdev->dev.kobj, &smsc47m1_group); | 785 | smsc47m1_remove_files(&pdev->dev); |
751 | 786 | ||
752 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 787 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
753 | smsc47m1_handle_resources(res->start, data->type, RELEASE, &pdev->dev); | 788 | smsc47m1_handle_resources(res->start, data->type, RELEASE, &pdev->dev); |