hc
2023-12-11 d2ccde1c8e90d38cee87a1b0309ad2827f3fd30d
kernel/drivers/hwmon/sis5595.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * sis5595.c - Part of lm_sensors, Linux kernel modules
34 * for hardware monitoring
....@@ -7,20 +8,6 @@
78 * Mark D. Studebaker <mdsxyz123@yahoo.com>
89 * Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with
910 * the help of Jean Delvare <jdelvare@suse.de>
10
- *
11
- * This program is free software; you can redistribute it and/or modify
12
- * it under the terms of the GNU General Public License as published by
13
- * the Free Software Foundation; either version 2 of the License, or
14
- * (at your option) any later version.
15
- *
16
- * This program is distributed in the hope that it will be useful,
17
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
18
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19
- * GNU General Public License for more details.
20
- *
21
- * You should have received a copy of the GNU General Public License
22
- * along with this program; if not, write to the Free Software
23
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
2411 */
2512
2613 /*
....@@ -66,7 +53,6 @@
6653 #include <linux/sysfs.h>
6754 #include <linux/acpi.h>
6855 #include <linux/io.h>
69
-
7056
7157 /*
7258 * If force_addr is set to anything different from 0, we forcibly enable
....@@ -222,7 +208,7 @@
222208 };
223209
224210 /* 4 Voltages */
225
-static ssize_t show_in(struct device *dev, struct device_attribute *da,
211
+static ssize_t in_show(struct device *dev, struct device_attribute *da,
226212 char *buf)
227213 {
228214 struct sis5595_data *data = sis5595_update_device(dev);
....@@ -231,7 +217,7 @@
231217 return sprintf(buf, "%d\n", IN_FROM_REG(data->in[nr]));
232218 }
233219
234
-static ssize_t show_in_min(struct device *dev, struct device_attribute *da,
220
+static ssize_t in_min_show(struct device *dev, struct device_attribute *da,
235221 char *buf)
236222 {
237223 struct sis5595_data *data = sis5595_update_device(dev);
....@@ -240,7 +226,7 @@
240226 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_min[nr]));
241227 }
242228
243
-static ssize_t show_in_max(struct device *dev, struct device_attribute *da,
229
+static ssize_t in_max_show(struct device *dev, struct device_attribute *da,
244230 char *buf)
245231 {
246232 struct sis5595_data *data = sis5595_update_device(dev);
....@@ -249,8 +235,8 @@
249235 return sprintf(buf, "%d\n", IN_FROM_REG(data->in_max[nr]));
250236 }
251237
252
-static ssize_t set_in_min(struct device *dev, struct device_attribute *da,
253
- const char *buf, size_t count)
238
+static ssize_t in_min_store(struct device *dev, struct device_attribute *da,
239
+ const char *buf, size_t count)
254240 {
255241 struct sis5595_data *data = dev_get_drvdata(dev);
256242 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -269,8 +255,8 @@
269255 return count;
270256 }
271257
272
-static ssize_t set_in_max(struct device *dev, struct device_attribute *da,
273
- const char *buf, size_t count)
258
+static ssize_t in_max_store(struct device *dev, struct device_attribute *da,
259
+ const char *buf, size_t count)
274260 {
275261 struct sis5595_data *data = dev_get_drvdata(dev);
276262 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -289,19 +275,21 @@
289275 return count;
290276 }
291277
292
-#define show_in_offset(offset) \
293
-static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
294
- show_in, NULL, offset); \
295
-static SENSOR_DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
296
- show_in_min, set_in_min, offset); \
297
-static SENSOR_DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
298
- show_in_max, set_in_max, offset);
299
-
300
-show_in_offset(0);
301
-show_in_offset(1);
302
-show_in_offset(2);
303
-show_in_offset(3);
304
-show_in_offset(4);
278
+static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0);
279
+static SENSOR_DEVICE_ATTR_RW(in0_min, in_min, 0);
280
+static SENSOR_DEVICE_ATTR_RW(in0_max, in_max, 0);
281
+static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1);
282
+static SENSOR_DEVICE_ATTR_RW(in1_min, in_min, 1);
283
+static SENSOR_DEVICE_ATTR_RW(in1_max, in_max, 1);
284
+static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2);
285
+static SENSOR_DEVICE_ATTR_RW(in2_min, in_min, 2);
286
+static SENSOR_DEVICE_ATTR_RW(in2_max, in_max, 2);
287
+static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3);
288
+static SENSOR_DEVICE_ATTR_RW(in3_min, in_min, 3);
289
+static SENSOR_DEVICE_ATTR_RW(in3_max, in_max, 3);
290
+static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4);
291
+static SENSOR_DEVICE_ATTR_RW(in4_min, in_min, 4);
292
+static SENSOR_DEVICE_ATTR_RW(in4_max, in_max, 4);
305293
306294 /* Temperature */
307295 static ssize_t temp1_input_show(struct device *dev,
....@@ -368,7 +356,7 @@
368356 static DEVICE_ATTR_RW(temp1_max_hyst);
369357
370358 /* 2 Fans */
371
-static ssize_t show_fan(struct device *dev, struct device_attribute *da,
359
+static ssize_t fan_show(struct device *dev, struct device_attribute *da,
372360 char *buf)
373361 {
374362 struct sis5595_data *data = sis5595_update_device(dev);
....@@ -378,7 +366,7 @@
378366 DIV_FROM_REG(data->fan_div[nr])));
379367 }
380368
381
-static ssize_t show_fan_min(struct device *dev, struct device_attribute *da,
369
+static ssize_t fan_min_show(struct device *dev, struct device_attribute *da,
382370 char *buf)
383371 {
384372 struct sis5595_data *data = sis5595_update_device(dev);
....@@ -388,8 +376,8 @@
388376 DIV_FROM_REG(data->fan_div[nr])));
389377 }
390378
391
-static ssize_t set_fan_min(struct device *dev, struct device_attribute *da,
392
- const char *buf, size_t count)
379
+static ssize_t fan_min_store(struct device *dev, struct device_attribute *da,
380
+ const char *buf, size_t count)
393381 {
394382 struct sis5595_data *data = dev_get_drvdata(dev);
395383 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -408,7 +396,7 @@
408396 return count;
409397 }
410398
411
-static ssize_t show_fan_div(struct device *dev, struct device_attribute *da,
399
+static ssize_t fan_div_show(struct device *dev, struct device_attribute *da,
412400 char *buf)
413401 {
414402 struct sis5595_data *data = sis5595_update_device(dev);
....@@ -423,8 +411,8 @@
423411 * least surprise; the user doesn't expect the fan minimum to change just
424412 * because the divisor changed.
425413 */
426
-static ssize_t set_fan_div(struct device *dev, struct device_attribute *da,
427
- const char *buf, size_t count)
414
+static ssize_t fan_div_store(struct device *dev, struct device_attribute *da,
415
+ const char *buf, size_t count)
428416 {
429417 struct sis5595_data *data = dev_get_drvdata(dev);
430418 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
....@@ -480,16 +468,12 @@
480468 return count;
481469 }
482470
483
-#define show_fan_offset(offset) \
484
-static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
485
- show_fan, NULL, offset - 1); \
486
-static SENSOR_DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
487
- show_fan_min, set_fan_min, offset - 1); \
488
-static SENSOR_DEVICE_ATTR(fan##offset##_div, S_IRUGO | S_IWUSR, \
489
- show_fan_div, set_fan_div, offset - 1);
490
-
491
-show_fan_offset(1);
492
-show_fan_offset(2);
471
+static SENSOR_DEVICE_ATTR_RO(fan1_input, fan, 0);
472
+static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0);
473
+static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0);
474
+static SENSOR_DEVICE_ATTR_RO(fan2_input, fan, 1);
475
+static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1);
476
+static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);
493477
494478 /* Alarms */
495479 static ssize_t alarms_show(struct device *dev, struct device_attribute *attr,
....@@ -500,21 +484,21 @@
500484 }
501485 static DEVICE_ATTR_RO(alarms);
502486
503
-static ssize_t show_alarm(struct device *dev, struct device_attribute *da,
487
+static ssize_t alarm_show(struct device *dev, struct device_attribute *da,
504488 char *buf)
505489 {
506490 struct sis5595_data *data = sis5595_update_device(dev);
507491 int nr = to_sensor_dev_attr(da)->index;
508492 return sprintf(buf, "%u\n", (data->alarms >> nr) & 1);
509493 }
510
-static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
511
-static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
512
-static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
513
-static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
514
-static SENSOR_DEVICE_ATTR(in4_alarm, S_IRUGO, show_alarm, NULL, 15);
515
-static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 6);
516
-static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 7);
517
-static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 15);
494
+static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0);
495
+static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1);
496
+static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2);
497
+static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3);
498
+static SENSOR_DEVICE_ATTR_RO(in4_alarm, alarm, 15);
499
+static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 6);
500
+static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 7);
501
+static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 15);
518502
519503 static ssize_t name_show(struct device *dev, struct device_attribute *attr,
520504 char *buf)
....@@ -672,7 +656,6 @@
672656
673657 return 0;
674658 }
675
-
676659
677660 /* ISA access must be locked explicitly. */
678661 static int sis5595_read_value(struct sis5595_data *data, u8 reg)