summaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorGuenter Roeck <linux@roeck-us.net>2018-12-10 17:02:19 -0500
committerGuenter Roeck <linux@roeck-us.net>2019-02-18 17:23:29 -0500
commite3a0ee1a8f3d5b404056cb969af9ba5b7ceccf95 (patch)
tree4f6513825f266948332c2c274e38e17b90d37bd9 /drivers/hwmon
parent86b9f565002954d32983f424a795f070ec6f6bbf (diff)
hwmon: (powr1220) 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')
-rw-r--r--drivers/hwmon/powr1220.c144
1 files changed, 52 insertions, 92 deletions
diff --git a/drivers/hwmon/powr1220.c b/drivers/hwmon/powr1220.c
index 3014e4ac741e..16c1c98e0e18 100644
--- a/drivers/hwmon/powr1220.c
+++ b/drivers/hwmon/powr1220.c
@@ -177,8 +177,9 @@ exit:
177} 177}
178 178
179/* Shows the voltage associated with the specified ADC channel */ 179/* Shows the voltage associated with the specified ADC channel */
180static ssize_t powr1220_show_voltage(struct device *dev, 180static ssize_t powr1220_voltage_show(struct device *dev,
181 struct device_attribute *dev_attr, char *buf) 181 struct device_attribute *dev_attr,
182 char *buf)
182{ 183{
183 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 184 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
184 int adc_val = powr1220_read_adc(dev, attr->index); 185 int adc_val = powr1220_read_adc(dev, attr->index);
@@ -190,8 +191,8 @@ static ssize_t powr1220_show_voltage(struct device *dev,
190} 191}
191 192
192/* Shows the maximum setting associated with the specified ADC channel */ 193/* Shows the maximum setting associated with the specified ADC channel */
193static ssize_t powr1220_show_max(struct device *dev, 194static ssize_t powr1220_max_show(struct device *dev,
194 struct device_attribute *dev_attr, char *buf) 195 struct device_attribute *dev_attr, char *buf)
195{ 196{
196 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 197 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
197 struct powr1220_data *data = dev_get_drvdata(dev); 198 struct powr1220_data *data = dev_get_drvdata(dev);
@@ -200,100 +201,59 @@ static ssize_t powr1220_show_max(struct device *dev,
200} 201}
201 202
202/* Shows the label associated with the specified ADC channel */ 203/* Shows the label associated with the specified ADC channel */
203static ssize_t powr1220_show_label(struct device *dev, 204static ssize_t powr1220_label_show(struct device *dev,
204 struct device_attribute *dev_attr, char *buf) 205 struct device_attribute *dev_attr,
206 char *buf)
205{ 207{
206 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr); 208 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
207 209
208 return sprintf(buf, "%s\n", input_names[attr->index]); 210 return sprintf(buf, "%s\n", input_names[attr->index]);
209} 211}
210 212
211static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, powr1220_show_voltage, NULL, 213static SENSOR_DEVICE_ATTR_RO(in0_input, powr1220_voltage, VMON1);
212 VMON1); 214static SENSOR_DEVICE_ATTR_RO(in1_input, powr1220_voltage, VMON2);
213static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, powr1220_show_voltage, NULL, 215static SENSOR_DEVICE_ATTR_RO(in2_input, powr1220_voltage, VMON3);
214 VMON2); 216static SENSOR_DEVICE_ATTR_RO(in3_input, powr1220_voltage, VMON4);
215static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, powr1220_show_voltage, NULL, 217static SENSOR_DEVICE_ATTR_RO(in4_input, powr1220_voltage, VMON5);
216 VMON3); 218static SENSOR_DEVICE_ATTR_RO(in5_input, powr1220_voltage, VMON6);
217static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, powr1220_show_voltage, NULL, 219static SENSOR_DEVICE_ATTR_RO(in6_input, powr1220_voltage, VMON7);
218 VMON4); 220static SENSOR_DEVICE_ATTR_RO(in7_input, powr1220_voltage, VMON8);
219static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, powr1220_show_voltage, NULL, 221static SENSOR_DEVICE_ATTR_RO(in8_input, powr1220_voltage, VMON9);
220 VMON5); 222static SENSOR_DEVICE_ATTR_RO(in9_input, powr1220_voltage, VMON10);
221static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, powr1220_show_voltage, NULL, 223static SENSOR_DEVICE_ATTR_RO(in10_input, powr1220_voltage, VMON11);
222 VMON6); 224static SENSOR_DEVICE_ATTR_RO(in11_input, powr1220_voltage, VMON12);
223static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, powr1220_show_voltage, NULL, 225static SENSOR_DEVICE_ATTR_RO(in12_input, powr1220_voltage, VCCA);
224 VMON7); 226static SENSOR_DEVICE_ATTR_RO(in13_input, powr1220_voltage, VCCINP);
225static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, powr1220_show_voltage, NULL, 227
226 VMON8); 228static SENSOR_DEVICE_ATTR_RO(in0_highest, powr1220_max, VMON1);
227static SENSOR_DEVICE_ATTR(in8_input, S_IRUGO, powr1220_show_voltage, NULL, 229static SENSOR_DEVICE_ATTR_RO(in1_highest, powr1220_max, VMON2);
228 VMON9); 230static SENSOR_DEVICE_ATTR_RO(in2_highest, powr1220_max, VMON3);
229static SENSOR_DEVICE_ATTR(in9_input, S_IRUGO, powr1220_show_voltage, NULL, 231static SENSOR_DEVICE_ATTR_RO(in3_highest, powr1220_max, VMON4);
230 VMON10); 232static SENSOR_DEVICE_ATTR_RO(in4_highest, powr1220_max, VMON5);
231static SENSOR_DEVICE_ATTR(in10_input, S_IRUGO, powr1220_show_voltage, NULL, 233static SENSOR_DEVICE_ATTR_RO(in5_highest, powr1220_max, VMON6);
232 VMON11); 234static SENSOR_DEVICE_ATTR_RO(in6_highest, powr1220_max, VMON7);
233static SENSOR_DEVICE_ATTR(in11_input, S_IRUGO, powr1220_show_voltage, NULL, 235static SENSOR_DEVICE_ATTR_RO(in7_highest, powr1220_max, VMON8);
234 VMON12); 236static SENSOR_DEVICE_ATTR_RO(in8_highest, powr1220_max, VMON9);
235static SENSOR_DEVICE_ATTR(in12_input, S_IRUGO, powr1220_show_voltage, NULL, 237static SENSOR_DEVICE_ATTR_RO(in9_highest, powr1220_max, VMON10);
236 VCCA); 238static SENSOR_DEVICE_ATTR_RO(in10_highest, powr1220_max, VMON11);
237static SENSOR_DEVICE_ATTR(in13_input, S_IRUGO, powr1220_show_voltage, NULL, 239static SENSOR_DEVICE_ATTR_RO(in11_highest, powr1220_max, VMON12);
238 VCCINP); 240static SENSOR_DEVICE_ATTR_RO(in12_highest, powr1220_max, VCCA);
239 241static SENSOR_DEVICE_ATTR_RO(in13_highest, powr1220_max, VCCINP);
240static SENSOR_DEVICE_ATTR(in0_highest, S_IRUGO, powr1220_show_max, NULL, 242
241 VMON1); 243static SENSOR_DEVICE_ATTR_RO(in0_label, powr1220_label, VMON1);
242static SENSOR_DEVICE_ATTR(in1_highest, S_IRUGO, powr1220_show_max, NULL, 244static SENSOR_DEVICE_ATTR_RO(in1_label, powr1220_label, VMON2);
243 VMON2); 245static SENSOR_DEVICE_ATTR_RO(in2_label, powr1220_label, VMON3);
244static SENSOR_DEVICE_ATTR(in2_highest, S_IRUGO, powr1220_show_max, NULL, 246static SENSOR_DEVICE_ATTR_RO(in3_label, powr1220_label, VMON4);
245 VMON3); 247static SENSOR_DEVICE_ATTR_RO(in4_label, powr1220_label, VMON5);
246static SENSOR_DEVICE_ATTR(in3_highest, S_IRUGO, powr1220_show_max, NULL, 248static SENSOR_DEVICE_ATTR_RO(in5_label, powr1220_label, VMON6);
247 VMON4); 249static SENSOR_DEVICE_ATTR_RO(in6_label, powr1220_label, VMON7);
248static SENSOR_DEVICE_ATTR(in4_highest, S_IRUGO, powr1220_show_max, NULL, 250static SENSOR_DEVICE_ATTR_RO(in7_label, powr1220_label, VMON8);
249 VMON5); 251static SENSOR_DEVICE_ATTR_RO(in8_label, powr1220_label, VMON9);
250static SENSOR_DEVICE_ATTR(in5_highest, S_IRUGO, powr1220_show_max, NULL, 252static SENSOR_DEVICE_ATTR_RO(in9_label, powr1220_label, VMON10);
251 VMON6); 253static SENSOR_DEVICE_ATTR_RO(in10_label, powr1220_label, VMON11);
252static SENSOR_DEVICE_ATTR(in6_highest, S_IRUGO, powr1220_show_max, NULL, 254static SENSOR_DEVICE_ATTR_RO(in11_label, powr1220_label, VMON12);
253 VMON7); 255static SENSOR_DEVICE_ATTR_RO(in12_label, powr1220_label, VCCA);
254static SENSOR_DEVICE_ATTR(in7_highest, S_IRUGO, powr1220_show_max, NULL, 256static SENSOR_DEVICE_ATTR_RO(in13_label, powr1220_label, VCCINP);
255 VMON8);
256static SENSOR_DEVICE_ATTR(in8_highest, S_IRUGO, powr1220_show_max, NULL,
257 VMON9);
258static SENSOR_DEVICE_ATTR(in9_highest, S_IRUGO, powr1220_show_max, NULL,
259 VMON10);
260static SENSOR_DEVICE_ATTR(in10_highest, S_IRUGO, powr1220_show_max, NULL,
261 VMON11);
262static SENSOR_DEVICE_ATTR(in11_highest, S_IRUGO, powr1220_show_max, NULL,
263 VMON12);
264static SENSOR_DEVICE_ATTR(in12_highest, S_IRUGO, powr1220_show_max, NULL,
265 VCCA);
266static SENSOR_DEVICE_ATTR(in13_highest, S_IRUGO, powr1220_show_max, NULL,
267 VCCINP);
268
269static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, powr1220_show_label, NULL,
270 VMON1);
271static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, powr1220_show_label, NULL,
272 VMON2);
273static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, powr1220_show_label, NULL,
274 VMON3);
275static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, powr1220_show_label, NULL,
276 VMON4);
277static SENSOR_DEVICE_ATTR(in4_label, S_IRUGO, powr1220_show_label, NULL,
278 VMON5);
279static SENSOR_DEVICE_ATTR(in5_label, S_IRUGO, powr1220_show_label, NULL,
280 VMON6);
281static SENSOR_DEVICE_ATTR(in6_label, S_IRUGO, powr1220_show_label, NULL,
282 VMON7);
283static SENSOR_DEVICE_ATTR(in7_label, S_IRUGO, powr1220_show_label, NULL,
284 VMON8);
285static SENSOR_DEVICE_ATTR(in8_label, S_IRUGO, powr1220_show_label, NULL,
286 VMON9);
287static SENSOR_DEVICE_ATTR(in9_label, S_IRUGO, powr1220_show_label, NULL,
288 VMON10);
289static SENSOR_DEVICE_ATTR(in10_label, S_IRUGO, powr1220_show_label, NULL,
290 VMON11);
291static SENSOR_DEVICE_ATTR(in11_label, S_IRUGO, powr1220_show_label, NULL,
292 VMON12);
293static SENSOR_DEVICE_ATTR(in12_label, S_IRUGO, powr1220_show_label, NULL,
294 VCCA);
295static SENSOR_DEVICE_ATTR(in13_label, S_IRUGO, powr1220_show_label, NULL,
296 VCCINP);
297 257
298static struct attribute *powr1220_attrs[] = { 258static struct attribute *powr1220_attrs[] = {
299 &sensor_dev_attr_in0_input.dev_attr.attr, 259 &sensor_dev_attr_in0_input.dev_attr.attr,