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:33 -0500 |
commit | 0594462f97058cb620ffb849b2ffb85e34cb43fe (patch) | |
tree | cf2dc41ffdd59cfbec0a94c91f0de22983801ae6 | |
parent | 6fdc5d7fa9471aba8eba6a1950dab704d313227f (diff) |
hwmon: (adc128d818) 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/adc128d818.c | 135 |
1 files changed, 55 insertions, 80 deletions
diff --git a/drivers/hwmon/adc128d818.c b/drivers/hwmon/adc128d818.c index bd2ca315c9d8..ca794bf904de 100644 --- a/drivers/hwmon/adc128d818.c +++ b/drivers/hwmon/adc128d818.c | |||
@@ -153,8 +153,8 @@ done: | |||
153 | return ret; | 153 | return ret; |
154 | } | 154 | } |
155 | 155 | ||
156 | static ssize_t adc128_show_in(struct device *dev, struct device_attribute *attr, | 156 | static ssize_t adc128_in_show(struct device *dev, |
157 | char *buf) | 157 | struct device_attribute *attr, char *buf) |
158 | { | 158 | { |
159 | struct adc128_data *data = adc128_update_device(dev); | 159 | struct adc128_data *data = adc128_update_device(dev); |
160 | int index = to_sensor_dev_attr_2(attr)->index; | 160 | int index = to_sensor_dev_attr_2(attr)->index; |
@@ -168,8 +168,9 @@ static ssize_t adc128_show_in(struct device *dev, struct device_attribute *attr, | |||
168 | return sprintf(buf, "%d\n", val); | 168 | return sprintf(buf, "%d\n", val); |
169 | } | 169 | } |
170 | 170 | ||
171 | static ssize_t adc128_set_in(struct device *dev, struct device_attribute *attr, | 171 | static ssize_t adc128_in_store(struct device *dev, |
172 | const char *buf, size_t count) | 172 | struct device_attribute *attr, const char *buf, |
173 | size_t count) | ||
173 | { | 174 | { |
174 | struct adc128_data *data = dev_get_drvdata(dev); | 175 | struct adc128_data *data = dev_get_drvdata(dev); |
175 | int index = to_sensor_dev_attr_2(attr)->index; | 176 | int index = to_sensor_dev_attr_2(attr)->index; |
@@ -193,7 +194,7 @@ static ssize_t adc128_set_in(struct device *dev, struct device_attribute *attr, | |||
193 | return count; | 194 | return count; |
194 | } | 195 | } |
195 | 196 | ||
196 | static ssize_t adc128_show_temp(struct device *dev, | 197 | static ssize_t adc128_temp_show(struct device *dev, |
197 | struct device_attribute *attr, char *buf) | 198 | struct device_attribute *attr, char *buf) |
198 | { | 199 | { |
199 | struct adc128_data *data = adc128_update_device(dev); | 200 | struct adc128_data *data = adc128_update_device(dev); |
@@ -207,9 +208,9 @@ static ssize_t adc128_show_temp(struct device *dev, | |||
207 | return sprintf(buf, "%d\n", temp * 500);/* 0.5 degrees C resolution */ | 208 | return sprintf(buf, "%d\n", temp * 500);/* 0.5 degrees C resolution */ |
208 | } | 209 | } |
209 | 210 | ||
210 | static ssize_t adc128_set_temp(struct device *dev, | 211 | static ssize_t adc128_temp_store(struct device *dev, |
211 | struct device_attribute *attr, | 212 | struct device_attribute *attr, |
212 | const char *buf, size_t count) | 213 | const char *buf, size_t count) |
213 | { | 214 | { |
214 | struct adc128_data *data = dev_get_drvdata(dev); | 215 | struct adc128_data *data = dev_get_drvdata(dev); |
215 | int index = to_sensor_dev_attr(attr)->index; | 216 | int index = to_sensor_dev_attr(attr)->index; |
@@ -233,7 +234,7 @@ static ssize_t adc128_set_temp(struct device *dev, | |||
233 | return count; | 234 | return count; |
234 | } | 235 | } |
235 | 236 | ||
236 | static ssize_t adc128_show_alarm(struct device *dev, | 237 | static ssize_t adc128_alarm_show(struct device *dev, |
237 | struct device_attribute *attr, char *buf) | 238 | struct device_attribute *attr, char *buf) |
238 | { | 239 | { |
239 | struct adc128_data *data = adc128_update_device(dev); | 240 | struct adc128_data *data = adc128_update_device(dev); |
@@ -272,77 +273,51 @@ static umode_t adc128_is_visible(struct kobject *kobj, | |||
272 | return attr->mode; | 273 | return attr->mode; |
273 | } | 274 | } |
274 | 275 | ||
275 | static SENSOR_DEVICE_ATTR_2(in0_input, S_IRUGO, | 276 | static SENSOR_DEVICE_ATTR_2_RO(in0_input, adc128_in, 0, 0); |
276 | adc128_show_in, NULL, 0, 0); | 277 | static SENSOR_DEVICE_ATTR_2_RW(in0_min, adc128_in, 0, 1); |
277 | static SENSOR_DEVICE_ATTR_2(in0_min, S_IWUSR | S_IRUGO, | 278 | static SENSOR_DEVICE_ATTR_2_RW(in0_max, adc128_in, 0, 2); |
278 | adc128_show_in, adc128_set_in, 0, 1); | 279 | |
279 | static SENSOR_DEVICE_ATTR_2(in0_max, S_IWUSR | S_IRUGO, | 280 | static SENSOR_DEVICE_ATTR_2_RO(in1_input, adc128_in, 1, 0); |
280 | adc128_show_in, adc128_set_in, 0, 2); | 281 | static SENSOR_DEVICE_ATTR_2_RW(in1_min, adc128_in, 1, 1); |
281 | 282 | static SENSOR_DEVICE_ATTR_2_RW(in1_max, adc128_in, 1, 2); | |
282 | static SENSOR_DEVICE_ATTR_2(in1_input, S_IRUGO, | 283 | |
283 | adc128_show_in, NULL, 1, 0); | 284 | static SENSOR_DEVICE_ATTR_2_RO(in2_input, adc128_in, 2, 0); |
284 | static SENSOR_DEVICE_ATTR_2(in1_min, S_IWUSR | S_IRUGO, | 285 | static SENSOR_DEVICE_ATTR_2_RW(in2_min, adc128_in, 2, 1); |
285 | adc128_show_in, adc128_set_in, 1, 1); | 286 | static SENSOR_DEVICE_ATTR_2_RW(in2_max, adc128_in, 2, 2); |
286 | static SENSOR_DEVICE_ATTR_2(in1_max, S_IWUSR | S_IRUGO, | 287 | |
287 | adc128_show_in, adc128_set_in, 1, 2); | 288 | static SENSOR_DEVICE_ATTR_2_RO(in3_input, adc128_in, 3, 0); |
288 | 289 | static SENSOR_DEVICE_ATTR_2_RW(in3_min, adc128_in, 3, 1); | |
289 | static SENSOR_DEVICE_ATTR_2(in2_input, S_IRUGO, | 290 | static SENSOR_DEVICE_ATTR_2_RW(in3_max, adc128_in, 3, 2); |
290 | adc128_show_in, NULL, 2, 0); | 291 | |
291 | static SENSOR_DEVICE_ATTR_2(in2_min, S_IWUSR | S_IRUGO, | 292 | static SENSOR_DEVICE_ATTR_2_RO(in4_input, adc128_in, 4, 0); |
292 | adc128_show_in, adc128_set_in, 2, 1); | 293 | static SENSOR_DEVICE_ATTR_2_RW(in4_min, adc128_in, 4, 1); |
293 | static SENSOR_DEVICE_ATTR_2(in2_max, S_IWUSR | S_IRUGO, | 294 | static SENSOR_DEVICE_ATTR_2_RW(in4_max, adc128_in, 4, 2); |
294 | adc128_show_in, adc128_set_in, 2, 2); | 295 | |
295 | 296 | static SENSOR_DEVICE_ATTR_2_RO(in5_input, adc128_in, 5, 0); | |
296 | static SENSOR_DEVICE_ATTR_2(in3_input, S_IRUGO, | 297 | static SENSOR_DEVICE_ATTR_2_RW(in5_min, adc128_in, 5, 1); |
297 | adc128_show_in, NULL, 3, 0); | 298 | static SENSOR_DEVICE_ATTR_2_RW(in5_max, adc128_in, 5, 2); |
298 | static SENSOR_DEVICE_ATTR_2(in3_min, S_IWUSR | S_IRUGO, | 299 | |
299 | adc128_show_in, adc128_set_in, 3, 1); | 300 | static SENSOR_DEVICE_ATTR_2_RO(in6_input, adc128_in, 6, 0); |
300 | static SENSOR_DEVICE_ATTR_2(in3_max, S_IWUSR | S_IRUGO, | 301 | static SENSOR_DEVICE_ATTR_2_RW(in6_min, adc128_in, 6, 1); |
301 | adc128_show_in, adc128_set_in, 3, 2); | 302 | static SENSOR_DEVICE_ATTR_2_RW(in6_max, adc128_in, 6, 2); |
302 | 303 | ||
303 | static SENSOR_DEVICE_ATTR_2(in4_input, S_IRUGO, | 304 | static SENSOR_DEVICE_ATTR_2_RO(in7_input, adc128_in, 7, 0); |
304 | adc128_show_in, NULL, 4, 0); | 305 | static SENSOR_DEVICE_ATTR_2_RW(in7_min, adc128_in, 7, 1); |
305 | static SENSOR_DEVICE_ATTR_2(in4_min, S_IWUSR | S_IRUGO, | 306 | static SENSOR_DEVICE_ATTR_2_RW(in7_max, adc128_in, 7, 2); |
306 | adc128_show_in, adc128_set_in, 4, 1); | 307 | |
307 | static SENSOR_DEVICE_ATTR_2(in4_max, S_IWUSR | S_IRUGO, | 308 | static SENSOR_DEVICE_ATTR_RO(temp1_input, adc128_temp, 0); |
308 | adc128_show_in, adc128_set_in, 4, 2); | 309 | static SENSOR_DEVICE_ATTR_RW(temp1_max, adc128_temp, 1); |
309 | 310 | static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, adc128_temp, 2); | |
310 | static SENSOR_DEVICE_ATTR_2(in5_input, S_IRUGO, | 311 | |
311 | adc128_show_in, NULL, 5, 0); | 312 | static SENSOR_DEVICE_ATTR_RO(in0_alarm, adc128_alarm, 0); |
312 | static SENSOR_DEVICE_ATTR_2(in5_min, S_IWUSR | S_IRUGO, | 313 | static SENSOR_DEVICE_ATTR_RO(in1_alarm, adc128_alarm, 1); |
313 | adc128_show_in, adc128_set_in, 5, 1); | 314 | static SENSOR_DEVICE_ATTR_RO(in2_alarm, adc128_alarm, 2); |
314 | static SENSOR_DEVICE_ATTR_2(in5_max, S_IWUSR | S_IRUGO, | 315 | static SENSOR_DEVICE_ATTR_RO(in3_alarm, adc128_alarm, 3); |
315 | adc128_show_in, adc128_set_in, 5, 2); | 316 | static SENSOR_DEVICE_ATTR_RO(in4_alarm, adc128_alarm, 4); |
316 | 317 | static SENSOR_DEVICE_ATTR_RO(in5_alarm, adc128_alarm, 5); | |
317 | static SENSOR_DEVICE_ATTR_2(in6_input, S_IRUGO, | 318 | static SENSOR_DEVICE_ATTR_RO(in6_alarm, adc128_alarm, 6); |
318 | adc128_show_in, NULL, 6, 0); | 319 | static SENSOR_DEVICE_ATTR_RO(in7_alarm, adc128_alarm, 7); |
319 | static SENSOR_DEVICE_ATTR_2(in6_min, S_IWUSR | S_IRUGO, | 320 | static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, adc128_alarm, 7); |
320 | adc128_show_in, adc128_set_in, 6, 1); | ||
321 | static SENSOR_DEVICE_ATTR_2(in6_max, S_IWUSR | S_IRUGO, | ||
322 | adc128_show_in, adc128_set_in, 6, 2); | ||
323 | |||
324 | static SENSOR_DEVICE_ATTR_2(in7_input, S_IRUGO, | ||
325 | adc128_show_in, NULL, 7, 0); | ||
326 | static SENSOR_DEVICE_ATTR_2(in7_min, S_IWUSR | S_IRUGO, | ||
327 | adc128_show_in, adc128_set_in, 7, 1); | ||
328 | static SENSOR_DEVICE_ATTR_2(in7_max, S_IWUSR | S_IRUGO, | ||
329 | adc128_show_in, adc128_set_in, 7, 2); | ||
330 | |||
331 | static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, adc128_show_temp, NULL, 0); | ||
332 | static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, | ||
333 | adc128_show_temp, adc128_set_temp, 1); | ||
334 | static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO, | ||
335 | adc128_show_temp, adc128_set_temp, 2); | ||
336 | |||
337 | static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, adc128_show_alarm, NULL, 0); | ||
338 | static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, adc128_show_alarm, NULL, 1); | ||
339 | static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, adc128_show_alarm, NULL, 2); | ||
340 | static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, adc128_show_alarm, NULL, 3); | ||
341 | static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, adc128_show_alarm, NULL, 4); | ||
342 | static SENSOR_DEVICE_ATTR(in5_alarm, S_IRUGO, adc128_show_alarm, NULL, 5); | ||
343 | static SENSOR_DEVICE_ATTR(in6_alarm, S_IRUGO, adc128_show_alarm, NULL, 6); | ||
344 | static SENSOR_DEVICE_ATTR(in7_alarm, S_IRUGO, adc128_show_alarm, NULL, 7); | ||
345 | static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, adc128_show_alarm, NULL, 7); | ||
346 | 321 | ||
347 | static struct attribute *adc128_attrs[] = { | 322 | static struct attribute *adc128_attrs[] = { |
348 | &sensor_dev_attr_in0_alarm.dev_attr.attr, | 323 | &sensor_dev_attr_in0_alarm.dev_attr.attr, |