diff options
author | Guenter Roeck <linux@roeck-us.net> | 2018-12-10 14:02:14 -0800 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-02-18 14:23:29 -0800 |
commit | ae868a2953f4af90e4963637070c7b2b28260168 (patch) | |
tree | ebc2017cfda44fea5458a3b1c145c352caf2c8a4 /drivers/hwmon/ltc4222.c | |
parent | 409e8bce6104ac56a4f51e389fb33e5596d40f6b (diff) | |
download | linux-ae868a2953f4af90e4963637070c7b2b28260168.tar.gz linux-ae868a2953f4af90e4963637070c7b2b28260168.tar.bz2 linux-ae868a2953f4af90e4963637070c7b2b28260168.zip |
hwmon: (ltc4222) 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/ltc4222.c')
-rw-r--r-- | drivers/hwmon/ltc4222.c | 56 |
1 files changed, 25 insertions, 31 deletions
diff --git a/drivers/hwmon/ltc4222.c b/drivers/hwmon/ltc4222.c index 88f747292816..32248f351a6e 100644 --- a/drivers/hwmon/ltc4222.c +++ b/drivers/hwmon/ltc4222.c @@ -94,7 +94,7 @@ static int ltc4222_get_value(struct device *dev, u8 reg) return val; } -static ssize_t ltc4222_show_value(struct device *dev, +static ssize_t ltc4222_value_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute *attr = to_sensor_dev_attr(da); @@ -106,7 +106,7 @@ static ssize_t ltc4222_show_value(struct device *dev, return snprintf(buf, PAGE_SIZE, "%d\n", value); } -static ssize_t ltc4222_show_bool(struct device *dev, +static ssize_t ltc4222_bool_show(struct device *dev, struct device_attribute *da, char *buf) { struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(da); @@ -125,45 +125,39 @@ static ssize_t ltc4222_show_bool(struct device *dev, } /* Voltages */ -static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4222_show_value, NULL, - LTC4222_SOURCE1); -static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4222_show_value, NULL, - LTC4222_ADIN1); -static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, ltc4222_show_value, NULL, - LTC4222_SOURCE2); -static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, ltc4222_show_value, NULL, - LTC4222_ADIN2); +static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4222_value, LTC4222_SOURCE1); +static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4222_value, LTC4222_ADIN1); +static SENSOR_DEVICE_ATTR_RO(in3_input, ltc4222_value, LTC4222_SOURCE2); +static SENSOR_DEVICE_ATTR_RO(in4_input, ltc4222_value, LTC4222_ADIN2); /* * Voltage alarms * UV/OV faults are associated with the input voltage, and power bad and fet * faults are associated with the output voltage. */ -static SENSOR_DEVICE_ATTR_2(in1_min_alarm, S_IRUGO, ltc4222_show_bool, NULL, - LTC4222_FAULT1, FAULT_UV); -static SENSOR_DEVICE_ATTR_2(in1_max_alarm, S_IRUGO, ltc4222_show_bool, NULL, - LTC4222_FAULT1, FAULT_OV); -static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, ltc4222_show_bool, NULL, - LTC4222_FAULT1, FAULT_POWER_BAD | FAULT_FET_BAD); - -static SENSOR_DEVICE_ATTR_2(in3_min_alarm, S_IRUGO, ltc4222_show_bool, NULL, - LTC4222_FAULT2, FAULT_UV); -static SENSOR_DEVICE_ATTR_2(in3_max_alarm, S_IRUGO, ltc4222_show_bool, NULL, - LTC4222_FAULT2, FAULT_OV); -static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, ltc4222_show_bool, NULL, - LTC4222_FAULT2, FAULT_POWER_BAD | FAULT_FET_BAD); +static SENSOR_DEVICE_ATTR_2_RO(in1_min_alarm, ltc4222_bool, LTC4222_FAULT1, + FAULT_UV); +static SENSOR_DEVICE_ATTR_2_RO(in1_max_alarm, ltc4222_bool, LTC4222_FAULT1, + FAULT_OV); +static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, ltc4222_bool, LTC4222_FAULT1, + FAULT_POWER_BAD | FAULT_FET_BAD); + +static SENSOR_DEVICE_ATTR_2_RO(in3_min_alarm, ltc4222_bool, LTC4222_FAULT2, + FAULT_UV); +static SENSOR_DEVICE_ATTR_2_RO(in3_max_alarm, ltc4222_bool, LTC4222_FAULT2, + FAULT_OV); +static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, ltc4222_bool, LTC4222_FAULT2, + FAULT_POWER_BAD | FAULT_FET_BAD); /* Current (via sense resistor) */ -static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4222_show_value, NULL, - LTC4222_SENSE1); -static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, ltc4222_show_value, NULL, - LTC4222_SENSE2); +static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4222_value, LTC4222_SENSE1); +static SENSOR_DEVICE_ATTR_RO(curr2_input, ltc4222_value, LTC4222_SENSE2); /* Overcurrent alarm */ -static SENSOR_DEVICE_ATTR_2(curr1_max_alarm, S_IRUGO, ltc4222_show_bool, NULL, - LTC4222_FAULT1, FAULT_OC); -static SENSOR_DEVICE_ATTR_2(curr2_max_alarm, S_IRUGO, ltc4222_show_bool, NULL, - LTC4222_FAULT2, FAULT_OC); +static SENSOR_DEVICE_ATTR_2_RO(curr1_max_alarm, ltc4222_bool, LTC4222_FAULT1, + FAULT_OC); +static SENSOR_DEVICE_ATTR_2_RO(curr2_max_alarm, ltc4222_bool, LTC4222_FAULT2, + FAULT_OC); static struct attribute *ltc4222_attrs[] = { &sensor_dev_attr_in1_input.dev_attr.attr, |