Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (adt7470) use permission-specific DEVICE_ATTR variants

Use 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 <Julia.Lawall@lip6.fr>
[groeck: Updated description]
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

authored by

Julia Lawall and committed by
Guenter Roeck
808fc6c2 b5751116

+21 -27
+21 -27
drivers/hwmon/adt7470.c
··· 403 403 return data; 404 404 } 405 405 406 - static ssize_t show_auto_update_interval(struct device *dev, 406 + static ssize_t auto_update_interval_show(struct device *dev, 407 407 struct device_attribute *devattr, 408 408 char *buf) 409 409 { ··· 411 411 return sprintf(buf, "%d\n", data->auto_update_interval); 412 412 } 413 413 414 - static ssize_t set_auto_update_interval(struct device *dev, 415 - struct device_attribute *devattr, 416 - const char *buf, 417 - size_t count) 414 + static ssize_t auto_update_interval_store(struct device *dev, 415 + struct device_attribute *devattr, 416 + const char *buf, size_t count) 418 417 { 419 418 struct adt7470_data *data = dev_get_drvdata(dev); 420 419 long temp; ··· 430 431 return count; 431 432 } 432 433 433 - static ssize_t show_num_temp_sensors(struct device *dev, 434 + static ssize_t num_temp_sensors_show(struct device *dev, 434 435 struct device_attribute *devattr, 435 436 char *buf) 436 437 { ··· 438 439 return sprintf(buf, "%d\n", data->num_temp_sensors); 439 440 } 440 441 441 - static ssize_t set_num_temp_sensors(struct device *dev, 442 - struct device_attribute *devattr, 443 - const char *buf, 444 - size_t count) 442 + static ssize_t num_temp_sensors_store(struct device *dev, 443 + struct device_attribute *devattr, 444 + const char *buf, size_t count) 445 445 { 446 446 struct adt7470_data *data = dev_get_drvdata(dev); 447 447 long temp; ··· 535 537 return sprintf(buf, "%d\n", 1000 * data->temp[attr->index]); 536 538 } 537 539 538 - static ssize_t show_alarm_mask(struct device *dev, 540 + static ssize_t alarm_mask_show(struct device *dev, 539 541 struct device_attribute *devattr, 540 542 char *buf) 541 543 { ··· 544 546 return sprintf(buf, "%x\n", data->alarms_mask); 545 547 } 546 548 547 - static ssize_t set_alarm_mask(struct device *dev, 548 - struct device_attribute *devattr, 549 - const char *buf, 550 - size_t count) 549 + static ssize_t alarm_mask_store(struct device *dev, 550 + struct device_attribute *devattr, 551 + const char *buf, size_t count) 551 552 { 552 553 struct adt7470_data *data = dev_get_drvdata(dev); 553 554 long mask; ··· 720 723 11, 15, 22, 29, 35, 44, 59, 88, 1400, 22500 721 724 }; 722 725 723 - static ssize_t show_pwm_freq(struct device *dev, 724 - struct device_attribute *devattr, char *buf) 726 + static ssize_t pwm1_freq_show(struct device *dev, 727 + struct device_attribute *devattr, char *buf) 725 728 { 726 729 struct adt7470_data *data = adt7470_update_device(dev); 727 730 unsigned char cfg_reg_1; ··· 742 745 return scnprintf(buf, PAGE_SIZE, "%d\n", adt7470_freq_map[index]); 743 746 } 744 747 745 - static ssize_t set_pwm_freq(struct device *dev, 746 - struct device_attribute *devattr, 747 - const char *buf, size_t count) 748 + static ssize_t pwm1_freq_store(struct device *dev, 749 + struct device_attribute *devattr, 750 + const char *buf, size_t count) 748 751 { 749 752 struct adt7470_data *data = dev_get_drvdata(dev); 750 753 struct i2c_client *client = data->client; ··· 1009 1012 return sprintf(buf, "0\n"); 1010 1013 } 1011 1014 1012 - static DEVICE_ATTR(alarm_mask, S_IWUSR | S_IRUGO, show_alarm_mask, 1013 - set_alarm_mask); 1014 - static DEVICE_ATTR(num_temp_sensors, S_IWUSR | S_IRUGO, show_num_temp_sensors, 1015 - set_num_temp_sensors); 1016 - static DEVICE_ATTR(auto_update_interval, S_IWUSR | S_IRUGO, 1017 - show_auto_update_interval, set_auto_update_interval); 1015 + static DEVICE_ATTR_RW(alarm_mask); 1016 + static DEVICE_ATTR_RW(num_temp_sensors); 1017 + static DEVICE_ATTR_RW(auto_update_interval); 1018 1018 1019 1019 static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max, 1020 1020 set_temp_max, 0); ··· 1127 1133 static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 2); 1128 1134 static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 3); 1129 1135 1130 - static DEVICE_ATTR(pwm1_freq, S_IWUSR | S_IRUGO, show_pwm_freq, set_pwm_freq); 1136 + static DEVICE_ATTR_RW(pwm1_freq); 1131 1137 1132 1138 static SENSOR_DEVICE_ATTR(pwm1_auto_point1_pwm, S_IWUSR | S_IRUGO, 1133 1139 show_pwm_min, set_pwm_min, 0);