From 1acd2e295ec4fb65feb47d0631b45ad22e9b01eb Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:21 -0800 Subject: [PATCH] hwmon: (tc654) Use permission specific SENSOR[_DEVICE]_ATTR variants Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code, to improve readability, and to reduce the chance of inconsistencies. Also replace any remaining S_ in the driver with octal values. The conversion was done automatically with coccinelle. The semantic patches and the scripts used to generate this commit log are available at https://github.com/groeck/coccinelle-patches/hwmon/. This patch does not introduce functional changes. It was verified by compiling the old and new files and comparing text and data sizes. Signed-off-by: Guenter Roeck --- drivers/hwmon/tc654.c | 60 +++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 33 deletions(-) diff --git a/drivers/hwmon/tc654.c b/drivers/hwmon/tc654.c index 18136e1f95fd..81dd229d7db4 100644 --- a/drivers/hwmon/tc654.c +++ b/drivers/hwmon/tc654.c @@ -200,7 +200,7 @@ out: * sysfs attributes */ -static ssize_t show_fan(struct device *dev, struct device_attribute *da, +static ssize_t fan_show(struct device *dev, struct device_attribute *da, char *buf) { int nr = to_sensor_dev_attr(da)->index; @@ -218,7 +218,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", val); } -static ssize_t show_fan_min(struct device *dev, struct device_attribute *da, +static ssize_t fan_min_show(struct device *dev, struct device_attribute *da, char *buf) { int nr = to_sensor_dev_attr(da)->index; @@ -231,8 +231,8 @@ static ssize_t show_fan_min(struct device *dev, struct device_attribute *da, TC654_FAN_FAULT_FROM_REG(data->fan_fault[nr])); } -static ssize_t set_fan_min(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) +static ssize_t fan_min_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) { int nr = to_sensor_dev_attr(da)->index; struct tc654_data *data = dev_get_drvdata(dev); @@ -255,7 +255,7 @@ static ssize_t set_fan_min(struct device *dev, struct device_attribute *da, return ret < 0 ? ret : count; } -static ssize_t show_fan_alarm(struct device *dev, struct device_attribute *da, +static ssize_t fan_alarm_show(struct device *dev, struct device_attribute *da, char *buf) { int nr = to_sensor_dev_attr(da)->index; @@ -275,8 +275,8 @@ static ssize_t show_fan_alarm(struct device *dev, struct device_attribute *da, static const u8 TC654_FAN_PULSE_SHIFT[] = { 1, 3 }; -static ssize_t show_fan_pulses(struct device *dev, struct device_attribute *da, - char *buf) +static ssize_t fan_pulses_show(struct device *dev, + struct device_attribute *da, char *buf) { int nr = to_sensor_dev_attr(da)->index; struct tc654_data *data = tc654_update_client(dev); @@ -289,8 +289,9 @@ static ssize_t show_fan_pulses(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", val); } -static ssize_t set_fan_pulses(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) +static ssize_t fan_pulses_store(struct device *dev, + struct device_attribute *da, const char *buf, + size_t count) { int nr = to_sensor_dev_attr(da)->index; struct tc654_data *data = dev_get_drvdata(dev); @@ -329,8 +330,8 @@ static ssize_t set_fan_pulses(struct device *dev, struct device_attribute *da, return ret < 0 ? ret : count; } -static ssize_t show_pwm_mode(struct device *dev, - struct device_attribute *da, char *buf) +static ssize_t pwm_mode_show(struct device *dev, struct device_attribute *da, + char *buf) { struct tc654_data *data = tc654_update_client(dev); @@ -340,9 +341,8 @@ static ssize_t show_pwm_mode(struct device *dev, return sprintf(buf, "%d\n", !!(data->config & TC654_REG_CONFIG_DUTYC)); } -static ssize_t set_pwm_mode(struct device *dev, - struct device_attribute *da, - const char *buf, size_t count) +static ssize_t pwm_mode_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) { struct tc654_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -371,7 +371,7 @@ static ssize_t set_pwm_mode(struct device *dev, static const int tc654_pwm_map[16] = { 77, 88, 102, 112, 124, 136, 148, 160, 172, 184, 196, 207, 219, 231, 243, 255}; -static ssize_t show_pwm(struct device *dev, struct device_attribute *da, +static ssize_t pwm_show(struct device *dev, struct device_attribute *da, char *buf) { struct tc654_data *data = tc654_update_client(dev); @@ -388,8 +388,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *da, return sprintf(buf, "%d\n", pwm); } -static ssize_t set_pwm(struct device *dev, struct device_attribute *da, - const char *buf, size_t count) +static ssize_t pwm_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) { struct tc654_data *data = dev_get_drvdata(dev); struct i2c_client *client = data->client; @@ -423,22 +423,16 @@ out: return ret < 0 ? ret : count; } -static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); -static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 0); -static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, - set_fan_min, 1); -static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0); -static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 1); -static SENSOR_DEVICE_ATTR(fan1_pulses, S_IWUSR | S_IRUGO, show_fan_pulses, - set_fan_pulses, 0); -static SENSOR_DEVICE_ATTR(fan2_pulses, S_IWUSR | S_IRUGO, show_fan_pulses, - set_fan_pulses, 1); -static SENSOR_DEVICE_ATTR(pwm1_mode, S_IWUSR | S_IRUGO, - show_pwm_mode, set_pwm_mode, 0); -static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, - set_pwm, 0); +static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1); +static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1); +static SENSOR_DEVICE_ATTR_RO(fan1_alarm, fan_alarm, 0); +static SENSOR_DEVICE_ATTR_RO(fan2_alarm, fan_alarm, 1); +static SENSOR_DEVICE_ATTR_RW(fan1_pulses, fan_pulses, 0); +static SENSOR_DEVICE_ATTR_RW(fan2_pulses, fan_pulses, 1); +static SENSOR_DEVICE_ATTR_RW(pwm1_mode, pwm_mode, 0); +static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0); /* Driver data */ static struct attribute *tc654_attrs[] = { -- 2.30.2