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

hwmon: (nsa320) 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
d0688f6c 1f856175

+6 -6
+6 -6
drivers/hwmon/nsa320-hwmon.c
··· 122 122 return sprintf(buf, "%s\n", nsa320_input_names[channel]); 123 123 } 124 124 125 - static ssize_t show_temp(struct device *dev, struct device_attribute *attr, 126 - char *buf) 125 + static ssize_t temp1_input_show(struct device *dev, 126 + struct device_attribute *attr, char *buf) 127 127 { 128 128 s32 mcu_data = nsa320_hwmon_update(dev); 129 129 ··· 133 133 return sprintf(buf, "%d\n", (mcu_data & 0xffff) * 100); 134 134 } 135 135 136 - static ssize_t show_fan(struct device *dev, struct device_attribute *attr, 137 - char *buf) 136 + static ssize_t fan1_input_show(struct device *dev, 137 + struct device_attribute *attr, char *buf) 138 138 { 139 139 s32 mcu_data = nsa320_hwmon_update(dev); 140 140 ··· 145 145 } 146 146 147 147 static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_label, NULL, NSA320_TEMP); 148 - static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL); 148 + static DEVICE_ATTR_RO(temp1_input); 149 149 static SENSOR_DEVICE_ATTR(fan1_label, S_IRUGO, show_label, NULL, NSA320_FAN); 150 - static DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL); 150 + static DEVICE_ATTR_RO(fan1_input); 151 151 152 152 static struct attribute *nsa320_attrs[] = { 153 153 &sensor_dev_attr_temp1_label.dev_attr.attr,