aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/aspeed-pwm-tacho.c
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2018-12-10 17:02:03 -0500
committerGuenter Roeck <linux@roeck-us.net>2018-12-16 18:13:39 -0500
commite98dd5388b24f8516a058e83a251681dbccfb0c0 (patch)
treeb11fdf2afc05002faba38a08f23b13a6ecc4823b /drivers/hwmon/aspeed-pwm-tacho.c
parent71ee4a400013ad187393b9cb32faee98d520516e (diff)
hwmon: (aspeed-pwm-tacho) 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. Cc: Joel Stanley <joel@jms.id.au> Cc: Andrew Jeffery <andrew@aj.id.au> Tested-by: Joel Stanley <joel@jms.id.au> Signed-off-by: Guenter Roeck <linux@roeck-us.net>
Diffstat (limited to 'drivers/hwmon/aspeed-pwm-tacho.c')
-rw-r--r--drivers/hwmon/aspeed-pwm-tacho.c80
1 files changed, 28 insertions, 52 deletions
diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c
index 92de8139d398..c4dd6301e7c8 100644
--- a/drivers/hwmon/aspeed-pwm-tacho.c
+++ b/drivers/hwmon/aspeed-pwm-tacho.c
@@ -570,8 +570,8 @@ static int aspeed_get_fan_tach_ch_rpm(struct aspeed_pwm_tacho_data *priv,
570 return (clk_source * 60) / (2 * raw_data * tach_div); 570 return (clk_source * 60) / (2 * raw_data * tach_div);
571} 571}
572 572
573static ssize_t set_pwm(struct device *dev, struct device_attribute *attr, 573static ssize_t pwm_store(struct device *dev, struct device_attribute *attr,
574 const char *buf, size_t count) 574 const char *buf, size_t count)
575{ 575{
576 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 576 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
577 int index = sensor_attr->index; 577 int index = sensor_attr->index;
@@ -595,7 +595,7 @@ static ssize_t set_pwm(struct device *dev, struct device_attribute *attr,
595 return count; 595 return count;
596} 596}
597 597
598static ssize_t show_pwm(struct device *dev, struct device_attribute *attr, 598static ssize_t pwm_show(struct device *dev, struct device_attribute *attr,
599 char *buf) 599 char *buf)
600{ 600{
601 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 601 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
@@ -605,7 +605,7 @@ static ssize_t show_pwm(struct device *dev, struct device_attribute *attr,
605 return sprintf(buf, "%u\n", priv->pwm_port_fan_ctrl[index]); 605 return sprintf(buf, "%u\n", priv->pwm_port_fan_ctrl[index]);
606} 606}
607 607
608static ssize_t show_rpm(struct device *dev, struct device_attribute *attr, 608static ssize_t rpm_show(struct device *dev, struct device_attribute *attr,
609 char *buf) 609 char *buf)
610{ 610{
611 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr); 611 struct sensor_device_attribute *sensor_attr = to_sensor_dev_attr(attr);
@@ -642,22 +642,14 @@ static umode_t fan_dev_is_visible(struct kobject *kobj,
642 return a->mode; 642 return a->mode;
643} 643}
644 644
645static SENSOR_DEVICE_ATTR(pwm1, 0644, 645static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0);
646 show_pwm, set_pwm, 0); 646static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1);
647static SENSOR_DEVICE_ATTR(pwm2, 0644, 647static SENSOR_DEVICE_ATTR_RW(pwm3, pwm, 2);
648 show_pwm, set_pwm, 1); 648static SENSOR_DEVICE_ATTR_RW(pwm4, pwm, 3);
649static SENSOR_DEVICE_ATTR(pwm3, 0644, 649static SENSOR_DEVICE_ATTR_RW(pwm5, pwm, 4);
650 show_pwm, set_pwm, 2); 650static SENSOR_DEVICE_ATTR_RW(pwm6, pwm, 5);
651static SENSOR_DEVICE_ATTR(pwm4, 0644, 651static SENSOR_DEVICE_ATTR_RW(pwm7, pwm, 6);
652 show_pwm, set_pwm, 3); 652static SENSOR_DEVICE_ATTR_RW(pwm8, pwm, 7);
653static SENSOR_DEVICE_ATTR(pwm5, 0644,
654 show_pwm, set_pwm, 4);
655static SENSOR_DEVICE_ATTR(pwm6, 0644,
656 show_pwm, set_pwm, 5);
657static SENSOR_DEVICE_ATTR(pwm7, 0644,
658 show_pwm, set_pwm, 6);
659static SENSOR_DEVICE_ATTR(pwm8, 0644,
660 show_pwm, set_pwm, 7);
661static struct attribute *pwm_dev_attrs[] = { 653static struct attribute *pwm_dev_attrs[] = {
662 &sensor_dev_attr_pwm1.dev_attr.attr, 654 &sensor_dev_attr_pwm1.dev_attr.attr,
663 &sensor_dev_attr_pwm2.dev_attr.attr, 655 &sensor_dev_attr_pwm2.dev_attr.attr,
@@ -675,38 +667,22 @@ static const struct attribute_group pwm_dev_group = {
675 .is_visible = pwm_is_visible, 667 .is_visible = pwm_is_visible,
676}; 668};
677 669
678static SENSOR_DEVICE_ATTR(fan1_input, 0444, 670static SENSOR_DEVICE_ATTR_RO(fan1_input, rpm, 0);
679 show_rpm, NULL, 0); 671static SENSOR_DEVICE_ATTR_RO(fan2_input, rpm, 1);
680static SENSOR_DEVICE_ATTR(fan2_input, 0444, 672static SENSOR_DEVICE_ATTR_RO(fan3_input, rpm, 2);
681 show_rpm, NULL, 1); 673static SENSOR_DEVICE_ATTR_RO(fan4_input, rpm, 3);
682static SENSOR_DEVICE_ATTR(fan3_input, 0444, 674static SENSOR_DEVICE_ATTR_RO(fan5_input, rpm, 4);
683 show_rpm, NULL, 2); 675static SENSOR_DEVICE_ATTR_RO(fan6_input, rpm, 5);
684static SENSOR_DEVICE_ATTR(fan4_input, 0444, 676static SENSOR_DEVICE_ATTR_RO(fan7_input, rpm, 6);
685 show_rpm, NULL, 3); 677static SENSOR_DEVICE_ATTR_RO(fan8_input, rpm, 7);
686static SENSOR_DEVICE_ATTR(fan5_input, 0444, 678static SENSOR_DEVICE_ATTR_RO(fan9_input, rpm, 8);
687 show_rpm, NULL, 4); 679static SENSOR_DEVICE_ATTR_RO(fan10_input, rpm, 9);
688static SENSOR_DEVICE_ATTR(fan6_input, 0444, 680static SENSOR_DEVICE_ATTR_RO(fan11_input, rpm, 10);
689 show_rpm, NULL, 5); 681static SENSOR_DEVICE_ATTR_RO(fan12_input, rpm, 11);
690static SENSOR_DEVICE_ATTR(fan7_input, 0444, 682static SENSOR_DEVICE_ATTR_RO(fan13_input, rpm, 12);
691 show_rpm, NULL, 6); 683static SENSOR_DEVICE_ATTR_RO(fan14_input, rpm, 13);
692static SENSOR_DEVICE_ATTR(fan8_input, 0444, 684static SENSOR_DEVICE_ATTR_RO(fan15_input, rpm, 14);
693 show_rpm, NULL, 7); 685static SENSOR_DEVICE_ATTR_RO(fan16_input, rpm, 15);
694static SENSOR_DEVICE_ATTR(fan9_input, 0444,
695 show_rpm, NULL, 8);
696static SENSOR_DEVICE_ATTR(fan10_input, 0444,
697 show_rpm, NULL, 9);
698static SENSOR_DEVICE_ATTR(fan11_input, 0444,
699 show_rpm, NULL, 10);
700static SENSOR_DEVICE_ATTR(fan12_input, 0444,
701 show_rpm, NULL, 11);
702static SENSOR_DEVICE_ATTR(fan13_input, 0444,
703 show_rpm, NULL, 12);
704static SENSOR_DEVICE_ATTR(fan14_input, 0444,
705 show_rpm, NULL, 13);
706static SENSOR_DEVICE_ATTR(fan15_input, 0444,
707 show_rpm, NULL, 14);
708static SENSOR_DEVICE_ATTR(fan16_input, 0444,
709 show_rpm, NULL, 15);
710static struct attribute *fan_dev_attrs[] = { 686static struct attribute *fan_dev_attrs[] = {
711 &sensor_dev_attr_fan1_input.dev_attr.attr, 687 &sensor_dev_attr_fan1_input.dev_attr.attr,
712 &sensor_dev_attr_fan2_input.dev_attr.attr, 688 &sensor_dev_attr_fan2_input.dev_attr.attr,