Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Julia Lawall and committed by
Guenter Roeck
8dfcdfc1 9bbacbfe

+28 -25
+28 -25
drivers/hwmon/w83627hf.c
··· 575 575 return sprintf(buf,"%ld\n", in0); 576 576 } 577 577 578 - static ssize_t show_regs_in_0(struct device *dev, struct device_attribute *attr, char *buf) 578 + static ssize_t in0_input_show(struct device *dev, 579 + struct device_attribute *attr, char *buf) 579 580 { 580 581 struct w83627hf_data *data = w83627hf_update_device(dev); 581 582 return show_in_0(data, buf, data->in[0]); 582 583 } 583 584 584 - static ssize_t show_regs_in_min0(struct device *dev, struct device_attribute *attr, char *buf) 585 + static ssize_t in0_min_show(struct device *dev, struct device_attribute *attr, 586 + char *buf) 585 587 { 586 588 struct w83627hf_data *data = w83627hf_update_device(dev); 587 589 return show_in_0(data, buf, data->in_min[0]); 588 590 } 589 591 590 - static ssize_t show_regs_in_max0(struct device *dev, struct device_attribute *attr, char *buf) 592 + static ssize_t in0_max_show(struct device *dev, struct device_attribute *attr, 593 + char *buf) 591 594 { 592 595 struct w83627hf_data *data = w83627hf_update_device(dev); 593 596 return show_in_0(data, buf, data->in_max[0]); 594 597 } 595 598 596 - static ssize_t store_regs_in_min0(struct device *dev, struct device_attribute *attr, 597 - const char *buf, size_t count) 599 + static ssize_t in0_min_store(struct device *dev, 600 + struct device_attribute *attr, const char *buf, 601 + size_t count) 598 602 { 599 603 struct w83627hf_data *data = dev_get_drvdata(dev); 600 604 unsigned long val; ··· 626 622 return count; 627 623 } 628 624 629 - static ssize_t store_regs_in_max0(struct device *dev, struct device_attribute *attr, 630 - const char *buf, size_t count) 625 + static ssize_t in0_max_store(struct device *dev, 626 + struct device_attribute *attr, const char *buf, 627 + size_t count) 631 628 { 632 629 struct w83627hf_data *data = dev_get_drvdata(dev); 633 630 unsigned long val; ··· 656 651 return count; 657 652 } 658 653 659 - static DEVICE_ATTR(in0_input, S_IRUGO, show_regs_in_0, NULL); 660 - static DEVICE_ATTR(in0_min, S_IRUGO | S_IWUSR, 661 - show_regs_in_min0, store_regs_in_min0); 662 - static DEVICE_ATTR(in0_max, S_IRUGO | S_IWUSR, 663 - show_regs_in_max0, store_regs_in_max0); 654 + static DEVICE_ATTR_RO(in0_input); 655 + static DEVICE_ATTR_RW(in0_min); 656 + static DEVICE_ATTR_RW(in0_max); 664 657 665 658 static ssize_t 666 659 show_fan_input(struct device *dev, struct device_attribute *devattr, char *buf) ··· 799 796 sysfs_temp_decl(3); 800 797 801 798 static ssize_t 802 - show_vid_reg(struct device *dev, struct device_attribute *attr, char *buf) 799 + cpu0_vid_show(struct device *dev, struct device_attribute *attr, char *buf) 803 800 { 804 801 struct w83627hf_data *data = w83627hf_update_device(dev); 805 802 return sprintf(buf, "%ld\n", (long) vid_from_reg(data->vid, data->vrm)); 806 803 } 807 - static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid_reg, NULL); 804 + static DEVICE_ATTR_RO(cpu0_vid); 808 805 809 806 static ssize_t 810 - show_vrm_reg(struct device *dev, struct device_attribute *attr, char *buf) 807 + vrm_show(struct device *dev, struct device_attribute *attr, char *buf) 811 808 { 812 809 struct w83627hf_data *data = dev_get_drvdata(dev); 813 810 return sprintf(buf, "%ld\n", (long) data->vrm); 814 811 } 815 812 static ssize_t 816 - store_vrm_reg(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) 813 + vrm_store(struct device *dev, struct device_attribute *attr, const char *buf, 814 + size_t count) 817 815 { 818 816 struct w83627hf_data *data = dev_get_drvdata(dev); 819 817 unsigned long val; ··· 830 826 831 827 return count; 832 828 } 833 - static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm_reg, store_vrm_reg); 829 + static DEVICE_ATTR_RW(vrm); 834 830 835 831 static ssize_t 836 - show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) 832 + alarms_show(struct device *dev, struct device_attribute *attr, char *buf) 837 833 { 838 834 struct w83627hf_data *data = w83627hf_update_device(dev); 839 835 return sprintf(buf, "%ld\n", (long) data->alarms); 840 836 } 841 - static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); 837 + static DEVICE_ATTR_RO(alarms); 842 838 843 839 static ssize_t 844 840 show_alarm(struct device *dev, struct device_attribute *attr, char *buf) ··· 864 860 static SENSOR_DEVICE_ATTR(temp3_alarm, S_IRUGO, show_alarm, NULL, 13); 865 861 866 862 static ssize_t 867 - show_beep_mask(struct device *dev, struct device_attribute *attr, char *buf) 863 + beep_mask_show(struct device *dev, struct device_attribute *attr, char *buf) 868 864 { 869 865 struct w83627hf_data *data = w83627hf_update_device(dev); 870 866 return sprintf(buf, "%ld\n", ··· 872 868 } 873 869 874 870 static ssize_t 875 - store_beep_mask(struct device *dev, struct device_attribute *attr, 871 + beep_mask_store(struct device *dev, struct device_attribute *attr, 876 872 const char *buf, size_t count) 877 873 { 878 874 struct w83627hf_data *data = dev_get_drvdata(dev); ··· 899 895 return count; 900 896 } 901 897 902 - static DEVICE_ATTR(beep_mask, S_IRUGO | S_IWUSR, 903 - show_beep_mask, store_beep_mask); 898 + static DEVICE_ATTR_RW(beep_mask); 904 899 905 900 static ssize_t 906 901 show_beep(struct device *dev, struct device_attribute *attr, char *buf) ··· 1267 1264 sysfs_temp_type(3); 1268 1265 1269 1266 static ssize_t 1270 - show_name(struct device *dev, struct device_attribute *devattr, char *buf) 1267 + name_show(struct device *dev, struct device_attribute *devattr, char *buf) 1271 1268 { 1272 1269 struct w83627hf_data *data = dev_get_drvdata(dev); 1273 1270 1274 1271 return sprintf(buf, "%s\n", data->name); 1275 1272 } 1276 - static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 1273 + static DEVICE_ATTR_RO(name); 1277 1274 1278 1275 static int __init w83627hf_find(int sioaddr, unsigned short *addr, 1279 1276 struct w83627hf_sio_data *sio_data)