From a4ec92ed8bc8ca8242b5f2205c255a384cf65710 Mon Sep 17 00:00:00 2001 From: Guenter Roeck Date: Mon, 10 Dec 2018 14:02:10 -0800 Subject: [PATCH] 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_ 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 --- drivers/hwmon/ina3221.c | 17 +++++++---------- 1 file 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 = { }; /* Extra attribute groups */ -static ssize_t ina3221_show_shunt(struct device *dev, +static ssize_t ina3221_shunt_show(struct device *dev, struct device_attribute *attr, char *buf) { struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); @@ -510,9 +510,9 @@ static ssize_t ina3221_show_shunt(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", input->shunt_resistor); } -static ssize_t ina3221_set_shunt(struct device *dev, - struct device_attribute *attr, - const char *buf, size_t count) +static ssize_t ina3221_shunt_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) { struct sensor_device_attribute *sd_attr = to_sensor_dev_attr(attr); struct ina3221_data *ina = dev_get_drvdata(dev); @@ -533,12 +533,9 @@ static ssize_t ina3221_set_shunt(struct device *dev, } /* shunt resistance */ -static SENSOR_DEVICE_ATTR(shunt1_resistor, S_IRUGO | S_IWUSR, - ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL1); -static SENSOR_DEVICE_ATTR(shunt2_resistor, S_IRUGO | S_IWUSR, - ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL2); -static SENSOR_DEVICE_ATTR(shunt3_resistor, S_IRUGO | S_IWUSR, - ina3221_show_shunt, ina3221_set_shunt, INA3221_CHANNEL3); +static SENSOR_DEVICE_ATTR_RW(shunt1_resistor, ina3221_shunt, INA3221_CHANNEL1); +static SENSOR_DEVICE_ATTR_RW(shunt2_resistor, ina3221_shunt, INA3221_CHANNEL2); +static SENSOR_DEVICE_ATTR_RW(shunt3_resistor, ina3221_shunt, INA3221_CHANNEL3); static struct attribute *ina3221_attrs[] = { &sensor_dev_attr_shunt1_resistor.dev_attr.attr,