diff options
author | Guenter Roeck <linux@roeck-us.net> | 2018-12-10 17:02:10 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-02-18 17:23:29 -0500 |
commit | a4ec92ed8bc8ca8242b5f2205c255a384cf65710 (patch) | |
tree | dd69d531e83c4093549e0f815136dc377e5a97fd /drivers/hwmon/ina3221.c | |
parent | 46dce7a19551470c25d27d69a56671da00a10545 (diff) |
hwmon: (ina3221) 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>
Diffstat (limited to 'drivers/hwmon/ina3221.c')
-rw-r--r-- | drivers/hwmon/ina3221.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/drivers/hwmon/ina3221.c b/drivers/hwmon/ina3221.c index e90ccac8bebb..f157214b3b83 100644 --- a/drivers/hwmon/ina3221.c +++ b/drivers/hwmon/ina3221.c | |||
@@ -499,7 +499,7 @@ static const struct hwmon_chip_info ina3221_chip_info = { | |||
499 | }; | 499 | }; |
500 | 500 | ||
501 | /* Extra attribute groups */ | 501 | /* Extra attribute groups */ |
502 | static ssize_t ina3221_show_shunt(struct device *dev, | 502 | static ssize_t ina3221_shunt_show(struct device *dev, |
503 | struct device_attribute *attr, char *buf) | 503 | struct device_attribute *attr, char *buf) |
504 | { | 504 | { |
505 | struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); | 505 | struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); |
@@ -510,9 +510,9 @@ static ssize_t ina3221_show_shunt(struct device *dev, | |||
510 | return snprintf(buf, PAGE_SIZE, "%d\n", input->shunt_resistor); | 510 | return snprintf(buf, PAGE_SIZE, "%d\n", input->shunt_resistor); |
511 | } | 511 | } |
512 | 512 | ||
513 | static ssize_t ina3221_set_shunt(struct device *dev, | 513 | static ssize_t ina3221_shunt_store(struct device *dev, |
514 | struct device_attribute *attr, | 514 | struct device_attribute *attr, |
515 | const char *buf, size_t count) | 515 | const char *buf, size_t count) |
516 | { | 516 | { |
517 | struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); | 517 | struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); |
518 | struct ina3221_data *ina = dev_get_drvdata(dev); | 518 | struct ina3221_data *ina = dev_get_drvdata(dev); |
@@ -533,12 +533,9 @@ static ssize_t ina3221_set_shunt(struct device *dev, | |||
533 | } | 533 | } |
534 | 534 | ||
535 | /* shunt resistance */ | 535 | /* shunt resistance */ |
536 | static SENSOR_DEVICE_ATTR(shunt1_resistor, S_IRUGO | S_IWUSR, | 536 | static SENSOR_DEVICE_ATTR_RW(shunt1_resistor, ina3221_shunt, INA3221_CHANNEL1); |
537 | ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL1); | 537 | static SENSOR_DEVICE_ATTR_RW(shunt2_resistor, ina3221_shunt, INA3221_CHANNEL2); |
538 | static SENSOR_DEVICE_ATTR(shunt2_resistor, S_IRUGO | S_IWUSR, | 538 | static SENSOR_DEVICE_ATTR_RW(shunt3_resistor, ina3221_shunt, INA3221_CHANNEL3); |
539 | ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL2); | ||
540 | static SENSOR_DEVICE_ATTR(shunt3_resistor, S_IRUGO | S_IWUSR, | ||
541 | ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL3); | ||
542 | 539 | ||
543 | static struct attribute *ina3221_attrs[] = { | 540 | static struct attribute *ina3221_attrs[] = { |
544 | &sensor_dev_attr_shunt1_resistor.dev_attr.attr, | 541 | &sensor_dev_attr_shunt1_resistor.dev_attr.attr, |