aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2018-12-10 17:02:21 -0500
committerGuenter Roeck <linux@roeck-us.net>2019-02-18 17:23:29 -0500
commit1acd2e295ec4fb65feb47d0631b45ad22e9b01eb (patch)
tree860e91c9f5dd712ec264f094586968d5a1cac72c
parentecd52d7bb674001f58c9b6026f24c3a0e9ac8350 (diff)
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_<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/tc654.c60
1 files 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:
200 * sysfs attributes 200 * sysfs attributes
201 */ 201 */
202 202
203static ssize_t show_fan(struct device *dev, struct device_attribute *da, 203static ssize_t fan_show(struct device *dev, struct device_attribute *da,
204 char *buf) 204 char *buf)
205{ 205{
206 int nr = to_sensor_dev_attr(da)->index; 206 int nr = to_sensor_dev_attr(da)->index;
@@ -218,7 +218,7 @@ static ssize_t show_fan(struct device *dev, struct device_attribute *da,
218 return sprintf(buf, "%d\n", val); 218 return sprintf(buf, "%d\n", val);
219} 219}
220 220
221static ssize_t show_fan_min(struct device *dev, struct device_attribute *da, 221static ssize_t fan_min_show(struct device *dev, struct device_attribute *da,
222 char *buf) 222 char *buf)
223{ 223{
224 int nr = to_sensor_dev_attr(da)->index; 224 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,
231 TC654_FAN_FAULT_FROM_REG(data->fan_fault[nr])); 231 TC654_FAN_FAULT_FROM_REG(data->fan_fault[nr]));
232} 232}
233 233
234static ssize_t set_fan_min(struct device *dev, struct device_attribute *da, 234static ssize_t fan_min_store(struct device *dev, struct device_attribute *da,
235 const char *buf, size_t count) 235 const char *buf, size_t count)
236{ 236{
237 int nr = to_sensor_dev_attr(da)->index; 237 int nr = to_sensor_dev_attr(da)->index;
238 struct tc654_data *data = dev_get_drvdata(dev); 238 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,
255 return ret < 0 ? ret : count; 255 return ret < 0 ? ret : count;
256} 256}
257 257
258static ssize_t show_fan_alarm(struct device *dev, struct device_attribute *da, 258static ssize_t fan_alarm_show(struct device *dev, struct device_attribute *da,
259 char *buf) 259 char *buf)
260{ 260{
261 int nr = to_sensor_dev_attr(da)->index; 261 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,
275 275
276static const u8 TC654_FAN_PULSE_SHIFT[] = { 1, 3 }; 276static const u8 TC654_FAN_PULSE_SHIFT[] = { 1, 3 };
277 277
278static ssize_t show_fan_pulses(struct device *dev, struct device_attribute *da, 278static ssize_t fan_pulses_show(struct device *dev,
279 char *buf) 279 struct device_attribute *da, char *buf)
280{ 280{
281 int nr = to_sensor_dev_attr(da)->index; 281 int nr = to_sensor_dev_attr(da)->index;
282 struct tc654_data *data = tc654_update_client(dev); 282 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,
289 return sprintf(buf, "%d\n", val); 289 return sprintf(buf, "%d\n", val);
290} 290}
291 291
292static ssize_t set_fan_pulses(struct device *dev, struct device_attribute *da, 292static ssize_t fan_pulses_store(struct device *dev,
293 const char *buf, size_t count) 293 struct device_attribute *da, const char *buf,
294 size_t count)
294{ 295{
295 int nr = to_sensor_dev_attr(da)->index; 296 int nr = to_sensor_dev_attr(da)->index;
296 struct tc654_data *data = dev_get_drvdata(dev); 297 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,
329 return ret < 0 ? ret : count; 330 return ret < 0 ? ret : count;
330} 331}
331 332
332static ssize_t show_pwm_mode(struct device *dev, 333static ssize_t pwm_mode_show(struct device *dev, struct device_attribute *da,
333 struct device_attribute *da, char *buf) 334 char *buf)
334{ 335{
335 struct tc654_data *data = tc654_update_client(dev); 336 struct tc654_data *data = tc654_update_client(dev);
336 337
@@ -340,9 +341,8 @@ static ssize_t show_pwm_mode(struct device *dev,
340 return sprintf(buf, "%d\n", !!(data->config & TC654_REG_CONFIG_DUTYC)); 341 return sprintf(buf, "%d\n", !!(data->config & TC654_REG_CONFIG_DUTYC));
341} 342}
342 343
343static ssize_t set_pwm_mode(struct device *dev, 344static ssize_t pwm_mode_store(struct device *dev, struct device_attribute *da,
344 struct device_attribute *da, 345 const char *buf, size_t count)
345 const char *buf, size_t count)
346{ 346{
347 struct tc654_data *data = dev_get_drvdata(dev); 347 struct tc654_data *data = dev_get_drvdata(dev);
348 struct i2c_client *client = data->client; 348 struct i2c_client *client = data->client;
@@ -371,7 +371,7 @@ static ssize_t set_pwm_mode(struct device *dev,
371static const int tc654_pwm_map[16] = { 77, 88, 102, 112, 124, 136, 148, 160, 371static const int tc654_pwm_map[16] = { 77, 88, 102, 112, 124, 136, 148, 160,
372 172, 184, 196, 207, 219, 231, 243, 255}; 372 172, 184, 196, 207, 219, 231, 243, 255};
373 373
374static ssize_t show_pwm(struct device *dev, struct device_attribute *da, 374static ssize_t pwm_show(struct device *dev, struct device_attribute *da,
375 char *buf) 375 char *buf)
376{ 376{
377 struct tc654_data *data = tc654_update_client(dev); 377 struct tc654_data *data = tc654_update_client(dev);
@@ -388,8 +388,8 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *da,
388 return sprintf(buf, "%d\n", pwm); 388 return sprintf(buf, "%d\n", pwm);
389} 389}
390 390
391static ssize_t set_pwm(struct device *dev, struct device_attribute *da, 391static ssize_t pwm_store(struct device *dev, struct device_attribute *da,
392 const char *buf, size_t count) 392 const char *buf, size_t count)
393{ 393{
394 struct tc654_data *data = dev_get_drvdata(dev); 394 struct tc654_data *data = dev_get_drvdata(dev);
395 struct i2c_client *client = data->client; 395 struct i2c_client *client = data->client;
@@ -423,22 +423,16 @@ out:
423 return ret < 0 ? ret : count; 423 return ret < 0 ? ret : count;
424} 424}
425 425
426static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0); 426static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0);
427static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1); 427static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1);
428static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR | S_IRUGO, show_fan_min, 428static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0);
429 set_fan_min, 0); 429static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1);
430static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR | S_IRUGO, show_fan_min, 430static SENSOR_DEVICE_ATTR_RO(fan1_alarm, fan_alarm, 0);
431 set_fan_min, 1); 431static SENSOR_DEVICE_ATTR_RO(fan2_alarm, fan_alarm, 1);
432static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_fan_alarm, NULL, 0); 432static SENSOR_DEVICE_ATTR_RW(fan1_pulses, fan_pulses, 0);
433static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_fan_alarm, NULL, 1); 433static SENSOR_DEVICE_ATTR_RW(fan2_pulses, fan_pulses, 1);
434static SENSOR_DEVICE_ATTR(fan1_pulses, S_IWUSR | S_IRUGO, show_fan_pulses, 434static SENSOR_DEVICE_ATTR_RW(pwm1_mode, pwm_mode, 0);
435 set_fan_pulses, 0); 435static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0);
436static SENSOR_DEVICE_ATTR(fan2_pulses, S_IWUSR | S_IRUGO, show_fan_pulses,
437 set_fan_pulses, 1);
438static SENSOR_DEVICE_ATTR(pwm1_mode, S_IWUSR | S_IRUGO,
439 show_pwm_mode, set_pwm_mode, 0);
440static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm,
441 set_pwm, 0);
442 436
443/* Driver data */ 437/* Driver data */
444static struct attribute *tc654_attrs[] = { 438static struct attribute *tc654_attrs[] = {