From 7fe6d2b90340ca77648d5d5aa3d9e7f97566efb8 Mon Sep 17 00:00:00 2001 From: Julia Lawall Date: Thu, 22 Dec 2016 13:05:13 +0100 Subject: hwmon: (w83792d) 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 [groeck: Updated description] Signed-off-by: Guenter Roeck --- drivers/hwmon/w83792d.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'drivers/hwmon/w83792d.c') diff --git a/drivers/hwmon/w83792d.c b/drivers/hwmon/w83792d.c index 0a8bce726b4b..d764602d70db 100644 --- a/drivers/hwmon/w83792d.c +++ b/drivers/hwmon/w83792d.c @@ -578,7 +578,7 @@ static ssize_t store_temp23(struct device *dev, struct device_attribute *attr, /* get realtime status of all sensors items: voltage, temp, fan */ static ssize_t -show_alarms_reg(struct device *dev, struct device_attribute *attr, char *buf) +alarms_show(struct device *dev, struct device_attribute *attr, char *buf) { struct w83792d_data *data = w83792d_update_device(dev); return sprintf(buf, "%d\n", data->alarms); @@ -735,16 +735,16 @@ store_pwm_mode(struct device *dev, struct device_attribute *attr, } static ssize_t -show_chassis_clear(struct device *dev, struct device_attribute *attr, - char *buf) +intrusion0_alarm_show(struct device *dev, struct device_attribute *attr, + char *buf) { struct w83792d_data *data = w83792d_update_device(dev); return sprintf(buf, "%d\n", data->chassis); } static ssize_t -store_chassis_clear(struct device *dev, struct device_attribute *attr, - const char *buf, size_t count) +intrusion0_alarm_store(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count) { struct i2c_client *client = to_i2c_client(dev); struct w83792d_data *data = i2c_get_clientdata(client); @@ -1047,7 +1047,7 @@ static SENSOR_DEVICE_ATTR_2(temp2_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 0, 4); static SENSOR_DEVICE_ATTR_2(temp3_max_hyst, S_IRUGO | S_IWUSR, show_temp23, store_temp23, 1, 4); -static DEVICE_ATTR(alarms, S_IRUGO, show_alarms_reg, NULL); +static DEVICE_ATTR_RO(alarms); static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0); static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1); static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 2); @@ -1067,8 +1067,7 @@ static SENSOR_DEVICE_ATTR(in8_alarm, S_IRUGO, show_alarm, NULL, 20); static SENSOR_DEVICE_ATTR(fan4_alarm, S_IRUGO, show_alarm, NULL, 21); static SENSOR_DEVICE_ATTR(fan5_alarm, S_IRUGO, show_alarm, NULL, 22); static SENSOR_DEVICE_ATTR(fan6_alarm, S_IRUGO, show_alarm, NULL, 23); -static DEVICE_ATTR(intrusion0_alarm, S_IRUGO | S_IWUSR, - show_chassis_clear, store_chassis_clear); +static DEVICE_ATTR_RW(intrusion0_alarm); static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 0); static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 1); static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, store_pwm, 2); -- cgit v1.2.3