summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/w83627hf.c
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2016-12-22 07:05:11 -0500
committerGuenter Roeck <linux@roeck-us.net>2017-01-02 13:19:45 -0500
commit8dfcdfc1e0cfdbc7645be6ddbfcca8cc57ee53e3 (patch)
treefc5fa5986adc7067108445d34dd9bbcc0fc489d1 /drivers/hwmon/w83627hf.c
parent9bbacbfe0e78738d57350677054bf977e711376a (diff)
hwmon: (w83627hf) use permission-specific DEVICE_ATTR variants
Use DEVICE_ATTR_RO for read-only attributes. This simplifies the source code, improves readbility, and reduces the chance of inconsistencies. The conversion was done automatically using coccinelle. It was validated by compiling both the old and the new source code and comparing its text, data, and bss size. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> [groeck: Updated description] Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/w83627hf.c')
-rw-r--r--drivers/hwmon/w83627hf.c53
1 files changed, 28 insertions, 25 deletions
diff --git a/drivers/hwmon/w83627hf.c b/drivers/hwmon/w83627hf.c
index 721295b9a051..8ac89d0781cc 100644
--- a/drivers/hwmon/w83627hf.c
+++ b/drivers/hwmon/w83627hf.c
@@ -575,26 +575,30 @@ static ssize_t show_in_0(struct w83627hf_data *data, char *buf, u8 reg)
575 return sprintf(buf,"%ld\n", in0); 575 return sprintf(buf,"%ld\n", in0);
576} 576}
577 577
578static ssize_t show_regs_in_0(struct device *dev, struct device_attribute *attr, char *buf) 578static ssize_t in0_input_show(struct device *dev,
579 struct device_attribute *attr, char *buf)
579{ 580{
580 struct w83627hf_data *data = w83627hf_update_device(dev); 581 struct w83627hf_data *data = w83627hf_update_device(dev);
581 return show_in_0(data, buf, data->in[0]); 582 return show_in_0(data, buf, data->in[0]);
582} 583}
583 584
584static ssize_t show_regs_in_min0(struct device *dev, struct device_attribute *attr, char *buf) 585static ssize_t in0_min_show(struct device *dev, struct device_attribute *attr,
586 char *buf)
585{ 587{
586 struct w83627hf_data *data = w83627hf_update_device(dev); 588 struct w83627hf_data *data = w83627hf_update_device(dev);
587 return show_in_0(data, buf, data->in_min[0]); 589 return show_in_0(data, buf, data->in_min[0]);
588} 590}
589 591
590static ssize_t show_regs_in_max0(struct device *dev, struct device_attribute *attr, char *buf) 592static ssize_t in0_max_show(struct device *dev, struct device_attribute *attr,
593 char *buf)
591{ 594{
592 struct w83627hf_data *data = w83627hf_update_device(dev); 595 struct w83627hf_data *data = w83627hf_update_device(dev);
593 return show_in_0(data, buf, data->in_max[0]); 596 return show_in_0(data, buf, data->in_max[0]);
594} 597}
595 598
596static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *attr, 599static ssize_t in0_min_store(struct device *dev,
597 const char *buf, size_t count) 600 struct device_attribute *attr, const char *buf,
601 size_t count)
598{ 602{
599 struct w83627hf_data *data = dev_get_drvdata(dev); 603 struct w83627hf_data *data = dev_get_drvdata(dev);
600 unsigned long val; 604 unsigned long val;
@@ -622,8 +626,9 @@ static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *a
622 return count; 626 return count;
623} 627}
624 628
625static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *attr, 629static ssize_t in0_max_store(struct device *dev,
626 const char *buf, size_t count) 630 struct device_attribute *attr, const char *buf,
631 size_t count)
627{ 632{
628 struct w83627hf_data *data = dev_get_drvdata(dev); 633 struct w83627hf_data *data = dev_get_drvdata(dev);
629 unsigned long val; 634 unsigned long val;
@@ -651,11 +656,9 @@ static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *a
651 return count; 656 return count;
652} 657}
653 658
654static DEVICE_ATTR(in0_input, S_IRUGO, show_regs_in_0, NULL); 659static DEVICE_ATTR_RO(in0_input);
655static DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR, 660static DEVICE_ATTR_RW(in0_min);
656 show_regs_in_min0, store_regs_in_min0); 661static DEVICE_ATTR_RW(in0_max);
657static DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR,
658 show_regs_in_max0, store_regs_in_max0);
659 662
660static ssize_t 663static ssize_t
661show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf) 664show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf)
@@ -796,21 +799,22 @@ sysfs_temp_decl(2);
796sysfs_temp_decl(3); 799sysfs_temp_decl(3);
797 800
798static ssize_t 801static ssize_t
799show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) 802cpu0_vid_show(struct device *dev, struct device_attribute *attr, char *buf)
800{ 803{
801 struct w83627hf_data *data = w83627hf_update_device(dev); 804 struct w83627hf_data *data = w83627hf_update_device(dev);
802 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); 805 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm));
803} 806}
804static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 807static DEVICE_ATTR_RO(cpu0_vid);
805 808
806static ssize_t 809static ssize_t
807show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 810vrm_show(struct device *dev, struct device_attribute *attr, char *buf)
808{ 811{
809 struct w83627hf_data *data = dev_get_drvdata(dev); 812 struct w83627hf_data *data = dev_get_drvdata(dev);
810 return sprintf(buf, "%ld\n", (long) data->vrm); 813 return sprintf(buf, "%ld\n", (long) data->vrm);
811} 814}
812static ssize_t 815static ssize_t
813store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 816vrm_store(struct device *dev, struct device_attribute *attr, const char *buf,
817 size_t count)
814{ 818{
815 struct w83627hf_data *data = dev_get_drvdata(dev); 819 struct w83627hf_data *data = dev_get_drvdata(dev);
816 unsigned long val; 820 unsigned long val;
@@ -826,15 +830,15 @@ store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf
826 830
827 return count; 831 return count;
828} 832}
829static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); 833static DEVICE_ATTR_RW(vrm);
830 834
831static ssize_t 835static ssize_t
832show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 836alarms_show(struct device *dev, struct device_attribute *attr, char *buf)
833{ 837{
834 struct w83627hf_data *data = w83627hf_update_device(dev); 838 struct w83627hf_data *data = w83627hf_update_device(dev);
835 return sprintf(buf, "%ld\n", (long) data->alarms); 839 return sprintf(buf, "%ld\n", (long) data->alarms);
836} 840}
837static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 841static DEVICE_ATTR_RO(alarms);
838 842
839static ssize_t 843static ssize_t
840show_alarm(struct device *dev, struct device_attribute *attr, char *buf) 844show_alarm(struct device *dev, struct device_attribute *attr, char *buf)
@@ -860,7 +864,7 @@ static SENSOR_DEVICE_ATTR(temp2_alarm, S_IRUGO, show_alarm, NULL, 5);
860static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); 864static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13);
861 865
862static ssize_t 866static ssize_t
863show_beep_mask(struct device *dev, struct device_attribute *attr, char *buf) 867beep_mask_show(struct device *dev, struct device_attribute *attr, char *buf)
864{ 868{
865 struct w83627hf_data *data = w83627hf_update_device(dev); 869 struct w83627hf_data *data = w83627hf_update_device(dev);
866 return sprintf(buf, "%ld\n", 870 return sprintf(buf, "%ld\n",
@@ -868,7 +872,7 @@ show_beep_mask(struct device *dev, struct device_attribute *attr, char *buf)
868} 872}
869 873
870static ssize_t 874static ssize_t
871store_beep_mask(struct device *dev, struct device_attribute *attr, 875beep_mask_store(struct device *dev, struct device_attribute *attr,
872 const char *buf, size_t count) 876 const char *buf, size_t count)
873{ 877{
874 struct w83627hf_data *data = dev_get_drvdata(dev); 878 struct w83627hf_data *data = dev_get_drvdata(dev);
@@ -895,8 +899,7 @@ store_beep_mask(struct device *dev, struct device_attribute *attr,
895 return count; 899 return count;
896} 900}
897 901
898static DEVICE_ATTR(beep_mask, S_IRUGO | S_IWUSR, 902static DEVICE_ATTR_RW(beep_mask);
899 show_beep_mask, store_beep_mask);
900 903
901static ssize_t 904static ssize_t
902show_beep(struct device *dev, struct device_attribute *attr, char *buf) 905show_beep(struct device *dev, struct device_attribute *attr, char *buf)
@@ -1264,13 +1267,13 @@ sysfs_temp_type(2);
1264sysfs_temp_type(3); 1267sysfs_temp_type(3);
1265 1268
1266static ssize_t 1269static ssize_t
1267show_name(struct device *dev, struct device_attribute *devattr, char *buf) 1270name_show(struct device *dev, struct device_attribute *devattr, char *buf)
1268{ 1271{
1269 struct w83627hf_data *data = dev_get_drvdata(dev); 1272 struct w83627hf_data *data = dev_get_drvdata(dev);
1270 1273
1271 return sprintf(buf, "%s\n", data->name); 1274 return sprintf(buf, "%s\n", data->name);
1272} 1275}
1273static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 1276static DEVICE_ATTR_RO(name);
1274 1277
1275static int __init w83627hf_find(int sioaddr, unsigned short *addr, 1278static int __init w83627hf_find(int sioaddr, unsigned short *addr,
1276 struct w83627hf_sio_data *sio_data) 1279 struct w83627hf_sio_data *sio_data)