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

hwmon: (adm1021) 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 comment]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Julia Lawall and committed by
Guenter Roeck
6b41013d 9bb2d47d

+7 -7
+7 -7
drivers/hwmon/adm1021.c
··· 191 191 return sprintf(buf, "%u\n", (data->alarms >> index) & 1); 192 192 } 193 193 194 - static ssize_t show_alarms(struct device *dev, 194 + static ssize_t alarms_show(struct device *dev, 195 195 struct device_attribute *attr, 196 196 char *buf) 197 197 { ··· 251 251 return count; 252 252 } 253 253 254 - static ssize_t show_low_power(struct device *dev, 254 + static ssize_t low_power_show(struct device *dev, 255 255 struct device_attribute *devattr, char *buf) 256 256 { 257 257 struct adm1021_data *data = adm1021_update_device(dev); 258 258 return sprintf(buf, "%d\n", data->low_power); 259 259 } 260 260 261 - static ssize_t set_low_power(struct device *dev, 262 - struct device_attribute *devattr, 263 - const char *buf, size_t count) 261 + static ssize_t low_power_store(struct device *dev, 262 + struct device_attribute *devattr, 263 + const char *buf, size_t count) 264 264 { 265 265 struct adm1021_data *data = dev_get_drvdata(dev); 266 266 struct i2c_client *client = data->client; ··· 303 303 static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); 304 304 static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); 305 305 306 - static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 307 - static DEVICE_ATTR(low_power, S_IWUSR | S_IRUGO, show_low_power, set_low_power); 306 + static DEVICE_ATTR_RO(alarms); 307 + static DEVICE_ATTR_RW(low_power); 308 308 309 309 static struct attribute *adm1021_attributes[] = { 310 310 &sensor_dev_attr_temp1_max.dev_attr.attr,