summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2016-12-22 07:04:30 -0500
committerGuenter Roeck <linux@roeck-us.net>2017-01-02 13:19:45 -0500
commit6b41013d6ee4e7fb63eddcc59be12032cf9c9bdb (patch)
tree94057c11bd71d8aa9371f741f6e092b203e9b8bb
parent9bb2d47d744dcb33ca896a023ee8fffc0bdbb3cf (diff)
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>
-rw-r--r--drivers/hwmon/adm1021.c14
1 files changed, 7 insertions, 7 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c
index 1fdcc3e703b9..eacf10fadbc6 100644
--- a/drivers/hwmon/adm1021.c
+++ b/drivers/hwmon/adm1021.c
@@ -191,7 +191,7 @@ static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
191 return sprintf(buf, "%u\n", (data->alarms >> index) & 1); 191 return sprintf(buf, "%u\n", (data->alarms >> index) & 1);
192} 192}
193 193
194static ssize_t show_alarms(struct device *dev, 194static ssize_t alarms_show(struct device *dev,
195 struct device_attribute *attr, 195 struct device_attribute *attr,
196 char *buf) 196 char *buf)
197{ 197{
@@ -251,16 +251,16 @@ static ssize_t set_temp_min(struct device *dev,
251 return count; 251 return count;
252} 252}
253 253
254static ssize_t show_low_power(struct device *dev, 254static ssize_t low_power_show(struct device *dev,
255 struct device_attribute *devattr, char *buf) 255 struct device_attribute *devattr, char *buf)
256{ 256{
257 struct adm1021_data *data = adm1021_update_device(dev); 257 struct adm1021_data *data = adm1021_update_device(dev);
258 return sprintf(buf, "%d\n", data->low_power); 258 return sprintf(buf, "%d\n", data->low_power);
259} 259}
260 260
261static ssize_t set_low_power(struct device *dev, 261static ssize_t low_power_store(struct device *dev,
262 struct device_attribute *devattr, 262 struct device_attribute *devattr,
263 const char *buf, size_t count) 263 const char *buf, size_t count)
264{ 264{
265 struct adm1021_data *data = dev_get_drvdata(dev); 265 struct adm1021_data *data = dev_get_drvdata(dev);
266 struct i2c_client *client = data->client; 266 struct i2c_client *client = data->client;
@@ -303,8 +303,8 @@ static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4);
303static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); 303static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3);
304static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); 304static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2);
305 305
306static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL); 306static DEVICE_ATTR_RO(alarms);
307static DEVICE_ATTR(low_power, S_IWUSR | S_IRUGO, show_low_power, set_low_power); 307static DEVICE_ATTR_RW(low_power);
308 308
309static struct attribute *adm1021_attributes[] = { 309static struct attribute *adm1021_attributes[] = {
310 &sensor_dev_attr_temp1_max.dev_attr.attr, 310 &sensor_dev_attr_temp1_max.dev_attr.attr,