diff options
author | Guenter Roeck <linux@roeck-us.net> | 2018-12-10 17:02:00 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2018-12-16 18:13:34 -0500 |
commit | cfc5bca6db53eb9ddc062a89993a29731d96c619 (patch) | |
tree | 6ef291065d74662beaefdd704f25859278c96eea | |
parent | b0c130fdaac18b69abcf577dfd21f84ec53c1eb9 (diff) |
hwmon: (adm1021) Use permission specific SENSOR[_DEVICE]_ATTR variants
Use SENSOR[_DEVICE]_ATTR[_2]_{RO,RW,WO} to simplify the source code,
to improve readbility, and to reduce the chance of inconsistencies.
Also replace any remaining S_<PERMS> 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 <linux@roeck-us.net>
-rw-r--r-- | drivers/hwmon/adm1021.c | 48 |
1 files changed, 22 insertions, 26 deletions
diff --git a/drivers/hwmon/adm1021.c b/drivers/hwmon/adm1021.c index eacf10fadbc6..49461b60e296 100644 --- a/drivers/hwmon/adm1021.c +++ b/drivers/hwmon/adm1021.c | |||
@@ -156,8 +156,8 @@ static struct adm1021_data *adm1021_update_device(struct device *dev) | |||
156 | return data; | 156 | return data; |
157 | } | 157 | } |
158 | 158 | ||
159 | static ssize_t show_temp(struct device *dev, | 159 | static ssize_t temp_show(struct device *dev, struct device_attribute *devattr, |
160 | struct device_attribute *devattr, char *buf) | 160 | char *buf) |
161 | { | 161 | { |
162 | int index = to_sensor_dev_attr(devattr)->index; | 162 | int index = to_sensor_dev_attr(devattr)->index; |
163 | struct adm1021_data *data = adm1021_update_device(dev); | 163 | struct adm1021_data *data = adm1021_update_device(dev); |
@@ -165,7 +165,7 @@ static ssize_t show_temp(struct device *dev, | |||
165 | return sprintf(buf, "%d\n", data->temp[index]); | 165 | return sprintf(buf, "%d\n", data->temp[index]); |
166 | } | 166 | } |
167 | 167 | ||
168 | static ssize_t show_temp_max(struct device *dev, | 168 | static ssize_t temp_max_show(struct device *dev, |
169 | struct device_attribute *devattr, char *buf) | 169 | struct device_attribute *devattr, char *buf) |
170 | { | 170 | { |
171 | int index = to_sensor_dev_attr(devattr)->index; | 171 | int index = to_sensor_dev_attr(devattr)->index; |
@@ -174,7 +174,7 @@ static ssize_t show_temp_max(struct device *dev, | |||
174 | return sprintf(buf, "%d\n", data->temp_max[index]); | 174 | return sprintf(buf, "%d\n", data->temp_max[index]); |
175 | } | 175 | } |
176 | 176 | ||
177 | static ssize_t show_temp_min(struct device *dev, | 177 | static ssize_t temp_min_show(struct device *dev, |
178 | struct device_attribute *devattr, char *buf) | 178 | struct device_attribute *devattr, char *buf) |
179 | { | 179 | { |
180 | int index = to_sensor_dev_attr(devattr)->index; | 180 | int index = to_sensor_dev_attr(devattr)->index; |
@@ -183,7 +183,7 @@ static ssize_t show_temp_min(struct device *dev, | |||
183 | return sprintf(buf, "%d\n", data->temp_min[index]); | 183 | return sprintf(buf, "%d\n", data->temp_min[index]); |
184 | } | 184 | } |
185 | 185 | ||
186 | static ssize_t show_alarm(struct device *dev, struct device_attribute *attr, | 186 | static ssize_t alarm_show(struct device *dev, struct device_attribute *attr, |
187 | char *buf) | 187 | char *buf) |
188 | { | 188 | { |
189 | int index = to_sensor_dev_attr(attr)->index; | 189 | int index = to_sensor_dev_attr(attr)->index; |
@@ -199,9 +199,9 @@ static ssize_t alarms_show(struct device *dev, | |||
199 | return sprintf(buf, "%u\n", data->alarms); | 199 | return sprintf(buf, "%u\n", data->alarms); |
200 | } | 200 | } |
201 | 201 | ||
202 | static ssize_t set_temp_max(struct device *dev, | 202 | static ssize_t temp_max_store(struct device *dev, |
203 | struct device_attribute *devattr, | 203 | struct device_attribute *devattr, |
204 | const char *buf, size_t count) | 204 | const char *buf, size_t count) |
205 | { | 205 | { |
206 | int index = to_sensor_dev_attr(devattr)->index; | 206 | int index = to_sensor_dev_attr(devattr)->index; |
207 | struct adm1021_data *data = dev_get_drvdata(dev); | 207 | struct adm1021_data *data = dev_get_drvdata(dev); |
@@ -225,9 +225,9 @@ static ssize_t set_temp_max(struct device *dev, | |||
225 | return count; | 225 | return count; |
226 | } | 226 | } |
227 | 227 | ||
228 | static ssize_t set_temp_min(struct device *dev, | 228 | static ssize_t temp_min_store(struct device *dev, |
229 | struct device_attribute *devattr, | 229 | struct device_attribute *devattr, |
230 | const char *buf, size_t count) | 230 | const char *buf, size_t count) |
231 | { | 231 | { |
232 | int index = to_sensor_dev_attr(devattr)->index; | 232 | int index = to_sensor_dev_attr(devattr)->index; |
233 | struct adm1021_data *data = dev_get_drvdata(dev); | 233 | struct adm1021_data *data = dev_get_drvdata(dev); |
@@ -287,21 +287,17 @@ static ssize_t low_power_store(struct device *dev, | |||
287 | } | 287 | } |
288 | 288 | ||
289 | 289 | ||
290 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0); | 290 | static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0); |
291 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, | 291 | static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0); |
292 | set_temp_max, 0); | 292 | static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0); |
293 | static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_temp_min, | 293 | static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1); |
294 | set_temp_min, 0); | 294 | static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1); |
295 | static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1); | 295 | static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1); |
296 | static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max, | 296 | static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 6); |
297 | set_temp_max, 1); | 297 | static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, alarm, 5); |
298 | static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_temp_min, | 298 | static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 4); |
299 | set_temp_min, 1); | 299 | static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, alarm, 3); |
300 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 6); | 300 | static SENSOR_DEVICE_ATTR_RO(temp2_fault, alarm, 2); |
301 | static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_alarm, NULL, 5); | ||
302 | static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 4); | ||
303 | static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_alarm, NULL, 3); | ||
304 | static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_alarm, NULL, 2); | ||
305 | 301 | ||
306 | static DEVICE_ATTR_RO(alarms); | 302 | static DEVICE_ATTR_RO(alarms); |
307 | static DEVICE_ATTR_RW(low_power); | 303 | static DEVICE_ATTR_RW(low_power); |