hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/sch5627.c
....@@ -1,20 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /***************************************************************************
23 * Copyright (C) 2010-2012 Hans de Goede <hdegoede@redhat.com> *
34 * *
4
- * This program is free software; you can redistribute it and/or modify *
5
- * it under the terms of the GNU General Public License as published by *
6
- * the Free Software Foundation; either version 2 of the License, or *
7
- * (at your option) any later version. *
8
- * *
9
- * This program is distributed in the hope that it will be useful, *
10
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
12
- * GNU General Public License for more details. *
13
- * *
14
- * You should have received a copy of the GNU General Public License *
15
- * along with this program; if not, write to the *
16
- * Free Software Foundation, Inc., *
17
- * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
185 ***************************************************************************/
196
207 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
....@@ -211,8 +198,8 @@
211198 return snprintf(buf, PAGE_SIZE, "%s\n", DEVNAME);
212199 }
213200
214
-static ssize_t show_temp(struct device *dev, struct device_attribute
215
- *devattr, char *buf)
201
+static ssize_t temp_show(struct device *dev, struct device_attribute *devattr,
202
+ char *buf)
216203 {
217204 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
218205 struct sch5627_data *data = sch5627_update_device(dev);
....@@ -225,8 +212,8 @@
225212 return snprintf(buf, PAGE_SIZE, "%d\n", val);
226213 }
227214
228
-static ssize_t show_temp_fault(struct device *dev, struct device_attribute
229
- *devattr, char *buf)
215
+static ssize_t temp_fault_show(struct device *dev,
216
+ struct device_attribute *devattr, char *buf)
230217 {
231218 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
232219 struct sch5627_data *data = sch5627_update_device(dev);
....@@ -237,8 +224,8 @@
237224 return snprintf(buf, PAGE_SIZE, "%d\n", data->temp[attr->index] == 0);
238225 }
239226
240
-static ssize_t show_temp_max(struct device *dev, struct device_attribute
241
- *devattr, char *buf)
227
+static ssize_t temp_max_show(struct device *dev,
228
+ struct device_attribute *devattr, char *buf)
242229 {
243230 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
244231 struct sch5627_data *data = dev_get_drvdata(dev);
....@@ -248,8 +235,8 @@
248235 return snprintf(buf, PAGE_SIZE, "%d\n", val);
249236 }
250237
251
-static ssize_t show_temp_crit(struct device *dev, struct device_attribute
252
- *devattr, char *buf)
238
+static ssize_t temp_crit_show(struct device *dev,
239
+ struct device_attribute *devattr, char *buf)
253240 {
254241 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
255242 struct sch5627_data *data = dev_get_drvdata(dev);
....@@ -259,8 +246,8 @@
259246 return snprintf(buf, PAGE_SIZE, "%d\n", val);
260247 }
261248
262
-static ssize_t show_fan(struct device *dev, struct device_attribute
263
- *devattr, char *buf)
249
+static ssize_t fan_show(struct device *dev, struct device_attribute *devattr,
250
+ char *buf)
264251 {
265252 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
266253 struct sch5627_data *data = sch5627_update_device(dev);
....@@ -276,8 +263,8 @@
276263 return snprintf(buf, PAGE_SIZE, "%d\n", val);
277264 }
278265
279
-static ssize_t show_fan_fault(struct device *dev, struct device_attribute
280
- *devattr, char *buf)
266
+static ssize_t fan_fault_show(struct device *dev,
267
+ struct device_attribute *devattr, char *buf)
281268 {
282269 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
283270 struct sch5627_data *data = sch5627_update_device(dev);
....@@ -289,8 +276,8 @@
289276 data->fan[attr->index] == 0xffff);
290277 }
291278
292
-static ssize_t show_fan_min(struct device *dev, struct device_attribute
293
- *devattr, char *buf)
279
+static ssize_t fan_min_show(struct device *dev,
280
+ struct device_attribute *devattr, char *buf)
294281 {
295282 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
296283 struct sch5627_data *data = dev_get_drvdata(dev);
....@@ -301,8 +288,8 @@
301288 return snprintf(buf, PAGE_SIZE, "%d\n", val);
302289 }
303290
304
-static ssize_t show_in(struct device *dev, struct device_attribute
305
- *devattr, char *buf)
291
+static ssize_t in_show(struct device *dev, struct device_attribute *devattr,
292
+ char *buf)
306293 {
307294 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
308295 struct sch5627_data *data = sch5627_update_device(dev);
....@@ -317,8 +304,8 @@
317304 return snprintf(buf, PAGE_SIZE, "%d\n", val);
318305 }
319306
320
-static ssize_t show_in_label(struct device *dev, struct device_attribute
321
- *devattr, char *buf)
307
+static ssize_t in_label_show(struct device *dev,
308
+ struct device_attribute *devattr, char *buf)
322309 {
323310 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
324311
....@@ -327,61 +314,61 @@
327314 }
328315
329316 static DEVICE_ATTR_RO(name);
330
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
331
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
332
-static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
333
-static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3);
334
-static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_temp, NULL, 4);
335
-static SENSOR_DEVICE_ATTR(temp6_input, S_IRUGO, show_temp, NULL, 5);
336
-static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_temp, NULL, 6);
337
-static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_temp, NULL, 7);
338
-static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0);
339
-static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1);
340
-static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2);
341
-static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_temp_fault, NULL, 3);
342
-static SENSOR_DEVICE_ATTR(temp5_fault, S_IRUGO, show_temp_fault, NULL, 4);
343
-static SENSOR_DEVICE_ATTR(temp6_fault, S_IRUGO, show_temp_fault, NULL, 5);
344
-static SENSOR_DEVICE_ATTR(temp7_fault, S_IRUGO, show_temp_fault, NULL, 6);
345
-static SENSOR_DEVICE_ATTR(temp8_fault, S_IRUGO, show_temp_fault, NULL, 7);
346
-static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO, show_temp_max, NULL, 0);
347
-static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO, show_temp_max, NULL, 1);
348
-static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO, show_temp_max, NULL, 2);
349
-static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO, show_temp_max, NULL, 3);
350
-static SENSOR_DEVICE_ATTR(temp5_max, S_IRUGO, show_temp_max, NULL, 4);
351
-static SENSOR_DEVICE_ATTR(temp6_max, S_IRUGO, show_temp_max, NULL, 5);
352
-static SENSOR_DEVICE_ATTR(temp7_max, S_IRUGO, show_temp_max, NULL, 6);
353
-static SENSOR_DEVICE_ATTR(temp8_max, S_IRUGO, show_temp_max, NULL, 7);
354
-static SENSOR_DEVICE_ATTR(temp1_crit, S_IRUGO, show_temp_crit, NULL, 0);
355
-static SENSOR_DEVICE_ATTR(temp2_crit, S_IRUGO, show_temp_crit, NULL, 1);
356
-static SENSOR_DEVICE_ATTR(temp3_crit, S_IRUGO, show_temp_crit, NULL, 2);
357
-static SENSOR_DEVICE_ATTR(temp4_crit, S_IRUGO, show_temp_crit, NULL, 3);
358
-static SENSOR_DEVICE_ATTR(temp5_crit, S_IRUGO, show_temp_crit, NULL, 4);
359
-static SENSOR_DEVICE_ATTR(temp6_crit, S_IRUGO, show_temp_crit, NULL, 5);
360
-static SENSOR_DEVICE_ATTR(temp7_crit, S_IRUGO, show_temp_crit, NULL, 6);
361
-static SENSOR_DEVICE_ATTR(temp8_crit, S_IRUGO, show_temp_crit, NULL, 7);
317
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
318
+static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
319
+static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2);
320
+static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3);
321
+static SENSOR_DEVICE_ATTR_RO(temp5_input, temp, 4);
322
+static SENSOR_DEVICE_ATTR_RO(temp6_input, temp, 5);
323
+static SENSOR_DEVICE_ATTR_RO(temp7_input, temp, 6);
324
+static SENSOR_DEVICE_ATTR_RO(temp8_input, temp, 7);
325
+static SENSOR_DEVICE_ATTR_RO(temp1_fault, temp_fault, 0);
326
+static SENSOR_DEVICE_ATTR_RO(temp2_fault, temp_fault, 1);
327
+static SENSOR_DEVICE_ATTR_RO(temp3_fault, temp_fault, 2);
328
+static SENSOR_DEVICE_ATTR_RO(temp4_fault, temp_fault, 3);
329
+static SENSOR_DEVICE_ATTR_RO(temp5_fault, temp_fault, 4);
330
+static SENSOR_DEVICE_ATTR_RO(temp6_fault, temp_fault, 5);
331
+static SENSOR_DEVICE_ATTR_RO(temp7_fault, temp_fault, 6);
332
+static SENSOR_DEVICE_ATTR_RO(temp8_fault, temp_fault, 7);
333
+static SENSOR_DEVICE_ATTR_RO(temp1_max, temp_max, 0);
334
+static SENSOR_DEVICE_ATTR_RO(temp2_max, temp_max, 1);
335
+static SENSOR_DEVICE_ATTR_RO(temp3_max, temp_max, 2);
336
+static SENSOR_DEVICE_ATTR_RO(temp4_max, temp_max, 3);
337
+static SENSOR_DEVICE_ATTR_RO(temp5_max, temp_max, 4);
338
+static SENSOR_DEVICE_ATTR_RO(temp6_max, temp_max, 5);
339
+static SENSOR_DEVICE_ATTR_RO(temp7_max, temp_max, 6);
340
+static SENSOR_DEVICE_ATTR_RO(temp8_max, temp_max, 7);
341
+static SENSOR_DEVICE_ATTR_RO(temp1_crit, temp_crit, 0);
342
+static SENSOR_DEVICE_ATTR_RO(temp2_crit, temp_crit, 1);
343
+static SENSOR_DEVICE_ATTR_RO(temp3_crit, temp_crit, 2);
344
+static SENSOR_DEVICE_ATTR_RO(temp4_crit, temp_crit, 3);
345
+static SENSOR_DEVICE_ATTR_RO(temp5_crit, temp_crit, 4);
346
+static SENSOR_DEVICE_ATTR_RO(temp6_crit, temp_crit, 5);
347
+static SENSOR_DEVICE_ATTR_RO(temp7_crit, temp_crit, 6);
348
+static SENSOR_DEVICE_ATTR_RO(temp8_crit, temp_crit, 7);
362349
363
-static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan, NULL, 0);
364
-static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan, NULL, 1);
365
-static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_fan, NULL, 2);
366
-static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_fan, NULL, 3);
367
-static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_fan_fault, NULL, 0);
368
-static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_fan_fault, NULL, 1);
369
-static SENSOR_DEVICE_ATTR(fan3_fault, S_IRUGO, show_fan_fault, NULL, 2);
370
-static SENSOR_DEVICE_ATTR(fan4_fault, S_IRUGO, show_fan_fault, NULL, 3);
371
-static SENSOR_DEVICE_ATTR(fan1_min, S_IRUGO, show_fan_min, NULL, 0);
372
-static SENSOR_DEVICE_ATTR(fan2_min, S_IRUGO, show_fan_min, NULL, 1);
373
-static SENSOR_DEVICE_ATTR(fan3_min, S_IRUGO, show_fan_min, NULL, 2);
374
-static SENSOR_DEVICE_ATTR(fan4_min, S_IRUGO, show_fan_min, NULL, 3);
350
+static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0);
351
+static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1);
352
+static SENSOR_DEVICE_ATTR_RO(fan3_input, fan, 2);
353
+static SENSOR_DEVICE_ATTR_RO(fan4_input, fan, 3);
354
+static SENSOR_DEVICE_ATTR_RO(fan1_fault, fan_fault, 0);
355
+static SENSOR_DEVICE_ATTR_RO(fan2_fault, fan_fault, 1);
356
+static SENSOR_DEVICE_ATTR_RO(fan3_fault, fan_fault, 2);
357
+static SENSOR_DEVICE_ATTR_RO(fan4_fault, fan_fault, 3);
358
+static SENSOR_DEVICE_ATTR_RO(fan1_min, fan_min, 0);
359
+static SENSOR_DEVICE_ATTR_RO(fan2_min, fan_min, 1);
360
+static SENSOR_DEVICE_ATTR_RO(fan3_min, fan_min, 2);
361
+static SENSOR_DEVICE_ATTR_RO(fan4_min, fan_min, 3);
375362
376
-static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, show_in, NULL, 0);
377
-static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_in, NULL, 1);
378
-static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_in, NULL, 2);
379
-static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_in, NULL, 3);
380
-static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_in, NULL, 4);
381
-static SENSOR_DEVICE_ATTR(in0_label, S_IRUGO, show_in_label, NULL, 0);
382
-static SENSOR_DEVICE_ATTR(in1_label, S_IRUGO, show_in_label, NULL, 1);
383
-static SENSOR_DEVICE_ATTR(in2_label, S_IRUGO, show_in_label, NULL, 2);
384
-static SENSOR_DEVICE_ATTR(in3_label, S_IRUGO, show_in_label, NULL, 3);
363
+static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0);
364
+static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1);
365
+static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2);
366
+static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3);
367
+static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4);
368
+static SENSOR_DEVICE_ATTR_RO(in0_label, in_label, 0);
369
+static SENSOR_DEVICE_ATTR_RO(in1_label, in_label, 1);
370
+static SENSOR_DEVICE_ATTR_RO(in2_label, in_label, 2);
371
+static SENSOR_DEVICE_ATTR_RO(in3_label, in_label, 3);
385372
386373 static struct attribute *sch5627_attributes[] = {
387374 &dev_attr_name.attr,