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

hwmon: (pc87360) use permission-specific DEVICE_ATTR variants

Use DEVICE_ATTR_RO for read only attributes and DEVICE_ATTR_RW for
read/write 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
e33110d0 93d72ac3

+13 -13
+13 -13
drivers/hwmon/pc87360.c
··· 589 589 &in_min_alarm[X].dev_attr.attr, \ 590 590 &in_max_alarm[X].dev_attr.attr 591 591 592 - static ssize_t show_vid(struct device *dev, struct device_attribute *attr, 593 - char *buf) 592 + static ssize_t cpu0_vid_show(struct device *dev, 593 + struct device_attribute *attr, char *buf) 594 594 { 595 595 struct pc87360_data *data = pc87360_update_device(dev); 596 596 return sprintf(buf, "%u\n", vid_from_reg(data->vid, data->vrm)); 597 597 } 598 - static DEVICE_ATTR(cpu0_vid, S_IRUGO, show_vid, NULL); 598 + static DEVICE_ATTR_RO(cpu0_vid); 599 599 600 - static ssize_t show_vrm(struct device *dev, struct device_attribute *attr, 600 + static ssize_t vrm_show(struct device *dev, struct device_attribute *attr, 601 601 char *buf) 602 602 { 603 603 struct pc87360_data *data = dev_get_drvdata(dev); 604 604 return sprintf(buf, "%u\n", data->vrm); 605 605 } 606 - static ssize_t set_vrm(struct device *dev, struct device_attribute *attr, 607 - const char *buf, size_t count) 606 + static ssize_t vrm_store(struct device *dev, struct device_attribute *attr, 607 + const char *buf, size_t count) 608 608 { 609 609 struct pc87360_data *data = dev_get_drvdata(dev); 610 610 unsigned long val; ··· 620 620 data->vrm = val; 621 621 return count; 622 622 } 623 - static DEVICE_ATTR(vrm, S_IRUGO | S_IWUSR, show_vrm, set_vrm); 623 + static DEVICE_ATTR_RW(vrm); 624 624 625 - static ssize_t show_in_alarms(struct device *dev, 625 + static ssize_t alarms_in_show(struct device *dev, 626 626 struct device_attribute *attr, char *buf) 627 627 { 628 628 struct pc87360_data *data = pc87360_update_device(dev); 629 629 return sprintf(buf, "%u\n", data->in_alarms); 630 630 } 631 - static DEVICE_ATTR(alarms_in, S_IRUGO, show_in_alarms, NULL); 631 + static DEVICE_ATTR_RO(alarms_in); 632 632 633 633 static struct attribute *pc8736x_vin_attr_array[] = { 634 634 VIN_UNIT_ATTRS(0), ··· 1006 1006 show_temp_crit, set_temp_crit, 2), 1007 1007 }; 1008 1008 1009 - static ssize_t show_temp_alarms(struct device *dev, 1009 + static ssize_t alarms_temp_show(struct device *dev, 1010 1010 struct device_attribute *attr, char *buf) 1011 1011 { 1012 1012 struct pc87360_data *data = pc87360_update_device(dev); 1013 1013 return sprintf(buf, "%u\n", data->temp_alarms); 1014 1014 } 1015 1015 1016 - static DEVICE_ATTR(alarms_temp, S_IRUGO, show_temp_alarms, NULL); 1016 + static DEVICE_ATTR_RO(alarms_temp); 1017 1017 1018 1018 /* 1019 1019 * show_temp_min/max_alarm() reads data from the per-channel status ··· 1106 1106 { .attrs = pc8736x_temp_attr[2] } 1107 1107 }; 1108 1108 1109 - static ssize_t show_name(struct device *dev, 1109 + static ssize_t name_show(struct device *dev, 1110 1110 struct device_attribute *devattr, char *buf) 1111 1111 { 1112 1112 struct pc87360_data *data = dev_get_drvdata(dev); 1113 1113 return sprintf(buf, "%s\n", data->name); 1114 1114 } 1115 1115 1116 - static DEVICE_ATTR(name, S_IRUGO, show_name, NULL); 1116 + static DEVICE_ATTR_RO(name); 1117 1117 1118 1118 /* 1119 1119 * Device detection, registration and update