diff options
author | Guenter Roeck <linux@roeck-us.net> | 2018-12-10 17:02:14 -0500 |
---|---|---|
committer | Guenter Roeck <linux@roeck-us.net> | 2019-02-18 17:23:29 -0500 |
commit | ae868a2953f4af90e4963637070c7b2b28260168 (patch) | |
tree | ebc2017cfda44fea5458a3b1c145c352caf2c8a4 /drivers/hwmon/ltc4222.c | |
parent | 409e8bce6104ac56a4f51e389fb33e5596d40f6b (diff) |
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) | |||
94 | return val; | 94 | return val; |
95 | } | 95 | } |
96 | 96 | ||
97 | static ssize_t ltc4222_show_value(struct device *dev, | 97 | static ssize_t ltc4222_value_show(struct device *dev, |
98 | struct device_attribute *da, char *buf) | 98 | struct device_attribute *da, char *buf) |
99 | { | 99 | { |
100 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); | 100 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
@@ -106,7 +106,7 @@ static ssize_t ltc4222_show_value(struct device *dev, | |||
106 | return snprintf(buf, PAGE_SIZE, "%d\n", value); | 106 | return snprintf(buf, PAGE_SIZE, "%d\n", value); |
107 | } | 107 | } |
108 | 108 | ||
109 | static ssize_t ltc4222_show_bool(struct device *dev, | 109 | static ssize_t ltc4222_bool_show(struct device *dev, |
110 | struct device_attribute *da, char *buf) | 110 | struct device_attribute *da, char *buf) |
111 | { | 111 | { |
112 | struct sensor_device_attribute_2 *attr = to_sensor_dev_attr_2(da); | 112 | 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, | |||
125 | } | 125 | } |
126 | 126 | ||
127 | /* Voltages */ | 127 | /* Voltages */ |
128 | static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ltc4222_show_value, NULL, | 128 | static SENSOR_DEVICE_ATTR_RO(in1_input, ltc4222_value, LTC4222_SOURCE1); |
129 | LTC4222_SOURCE1); | 129 | static SENSOR_DEVICE_ATTR_RO(in2_input, ltc4222_value, LTC4222_ADIN1); |
130 | static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ltc4222_show_value, NULL, | 130 | static SENSOR_DEVICE_ATTR_RO(in3_input, ltc4222_value, LTC4222_SOURCE2); |
131 | LTC4222_ADIN1); | 131 | static SENSOR_DEVICE_ATTR_RO(in4_input, ltc4222_value, LTC4222_ADIN2); |
132 | static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, ltc4222_show_value, NULL, | ||
133 | LTC4222_SOURCE2); | ||
134 | static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, ltc4222_show_value, NULL, | ||
135 | LTC4222_ADIN2); | ||
136 | 132 | ||
137 | /* | 133 | /* |
138 | * Voltage alarms | 134 | * Voltage alarms |
139 | * UV/OV faults are associated with the input voltage, and power bad and fet | 135 | * UV/OV faults are associated with the input voltage, and power bad and fet |
140 | * faults are associated with the output voltage. | 136 | * faults are associated with the output voltage. |
141 | */ | 137 | */ |
142 | static SENSOR_DEVICE_ATTR_2(in1_min_alarm, S_IRUGO, ltc4222_show_bool, NULL, | 138 | static SENSOR_DEVICE_ATTR_2_RO(in1_min_alarm, ltc4222_bool, LTC4222_FAULT1, |
143 | LTC4222_FAULT1, FAULT_UV); | 139 | FAULT_UV); |
144 | static SENSOR_DEVICE_ATTR_2(in1_max_alarm, S_IRUGO, ltc4222_show_bool, NULL, | 140 | static SENSOR_DEVICE_ATTR_2_RO(in1_max_alarm, ltc4222_bool, LTC4222_FAULT1, |
145 | LTC4222_FAULT1, FAULT_OV); | 141 | FAULT_OV); |
146 | static SENSOR_DEVICE_ATTR_2(in2_alarm, S_IRUGO, ltc4222_show_bool, NULL, | 142 | static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, ltc4222_bool, LTC4222_FAULT1, |
147 | LTC4222_FAULT1, FAULT_POWER_BAD | FAULT_FET_BAD); | 143 | FAULT_POWER_BAD | FAULT_FET_BAD); |
148 | 144 | ||
149 | static SENSOR_DEVICE_ATTR_2(in3_min_alarm, S_IRUGO, ltc4222_show_bool, NULL, | 145 | static SENSOR_DEVICE_ATTR_2_RO(in3_min_alarm, ltc4222_bool, LTC4222_FAULT2, |
150 | LTC4222_FAULT2, FAULT_UV); | 146 | FAULT_UV); |
151 | static SENSOR_DEVICE_ATTR_2(in3_max_alarm, S_IRUGO, ltc4222_show_bool, NULL, | 147 | static SENSOR_DEVICE_ATTR_2_RO(in3_max_alarm, ltc4222_bool, LTC4222_FAULT2, |
152 | LTC4222_FAULT2, FAULT_OV); | 148 | FAULT_OV); |
153 | static SENSOR_DEVICE_ATTR_2(in4_alarm, S_IRUGO, ltc4222_show_bool, NULL, | 149 | static SENSOR_DEVICE_ATTR_2_RO(in4_alarm, ltc4222_bool, LTC4222_FAULT2, |
154 | LTC4222_FAULT2, FAULT_POWER_BAD | FAULT_FET_BAD); | 150 | FAULT_POWER_BAD | FAULT_FET_BAD); |
155 | 151 | ||
156 | /* Current (via sense resistor) */ | 152 | /* Current (via sense resistor) */ |
157 | static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, ltc4222_show_value, NULL, | 153 | static SENSOR_DEVICE_ATTR_RO(curr1_input, ltc4222_value, LTC4222_SENSE1); |
158 | LTC4222_SENSE1); | 154 | static SENSOR_DEVICE_ATTR_RO(curr2_input, ltc4222_value, LTC4222_SENSE2); |
159 | static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, ltc4222_show_value, NULL, | ||
160 | LTC4222_SENSE2); | ||
161 | 155 | ||
162 | /* Overcurrent alarm */ | 156 | /* Overcurrent alarm */ |
163 | static SENSOR_DEVICE_ATTR_2(curr1_max_alarm, S_IRUGO, ltc4222_show_bool, NULL, | 157 | static SENSOR_DEVICE_ATTR_2_RO(curr1_max_alarm, ltc4222_bool, LTC4222_FAULT1, |
164 | LTC4222_FAULT1, FAULT_OC); | 158 | FAULT_OC); |
165 | static SENSOR_DEVICE_ATTR_2(curr2_max_alarm, S_IRUGO, ltc4222_show_bool, NULL, | 159 | static SENSOR_DEVICE_ATTR_2_RO(curr2_max_alarm, ltc4222_bool, LTC4222_FAULT2, |
166 | LTC4222_FAULT2, FAULT_OC); | 160 | FAULT_OC); |
167 | 161 | ||
168 | static struct attribute *ltc4222_attrs[] = { | 162 | static struct attribute *ltc4222_attrs[] = { |
169 | &sensor_dev_attr_in1_input.dev_attr.attr, | 163 | &sensor_dev_attr_in1_input.dev_attr.attr, |