hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/menf21bmc_hwmon.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * MEN 14F021P00 Board Management Controller (BMC) hwmon driver.
34 *
....@@ -6,11 +7,6 @@
67 * driver through sysfs.
78 *
89 * Copyright (C) 2014 MEN Mikro Elektronik Nuernberg GmbH
9
- *
10
- * This program is free software; you can redistribute it and/or modify it
11
- * under the terms of the GNU General Public License as published by the
12
- * Free Software Foundation; either version 2 of the License, or (at your
13
- * option) any later version.
1410 */
1511
1612 #include <linux/module.h>
....@@ -101,7 +97,7 @@
10197 }
10298
10399 static ssize_t
104
-show_label(struct device *dev, struct device_attribute *devattr, char *buf)
100
+label_show(struct device *dev, struct device_attribute *devattr, char *buf)
105101 {
106102 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
107103
....@@ -109,7 +105,7 @@
109105 }
110106
111107 static ssize_t
112
-show_in(struct device *dev, struct device_attribute *devattr, char *buf)
108
+in_show(struct device *dev, struct device_attribute *devattr, char *buf)
113109 {
114110 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
115111 struct menf21bmc_hwmon *drv_data = menf21bmc_hwmon_update(dev);
....@@ -121,7 +117,7 @@
121117 }
122118
123119 static ssize_t
124
-show_min(struct device *dev, struct device_attribute *devattr, char *buf)
120
+min_show(struct device *dev, struct device_attribute *devattr, char *buf)
125121 {
126122 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
127123 struct menf21bmc_hwmon *drv_data = dev_get_drvdata(dev);
....@@ -130,7 +126,7 @@
130126 }
131127
132128 static ssize_t
133
-show_max(struct device *dev, struct device_attribute *devattr, char *buf)
129
+max_show(struct device *dev, struct device_attribute *devattr, char *buf)
134130 {
135131 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
136132 struct menf21bmc_hwmon *drv_data = dev_get_drvdata(dev);
....@@ -138,21 +134,26 @@
138134 return sprintf(buf, "%d\n", drv_data->in_max[attr->index]);
139135 }
140136
141
-#define create_voltage_sysfs(idx) \
142
-static SENSOR_DEVICE_ATTR(in##idx##_input, S_IRUGO, \
143
- show_in, NULL, idx); \
144
-static SENSOR_DEVICE_ATTR(in##idx##_min, S_IRUGO, \
145
- show_min, NULL, idx); \
146
-static SENSOR_DEVICE_ATTR(in##idx##_max, S_IRUGO, \
147
- show_max, NULL, idx); \
148
-static SENSOR_DEVICE_ATTR(in##idx##_label, S_IRUGO, \
149
- show_label, NULL, idx);
150
-
151
-create_voltage_sysfs(0);
152
-create_voltage_sysfs(1);
153
-create_voltage_sysfs(2);
154
-create_voltage_sysfs(3);
155
-create_voltage_sysfs(4);
137
+static SENSOR_DEVICE_ATTR_RO(in0_input, in, 0);
138
+static SENSOR_DEVICE_ATTR_RO(in0_min, min, 0);
139
+static SENSOR_DEVICE_ATTR_RO(in0_max, max, 0);
140
+static SENSOR_DEVICE_ATTR_RO(in0_label, label, 0);
141
+static SENSOR_DEVICE_ATTR_RO(in1_input, in, 1);
142
+static SENSOR_DEVICE_ATTR_RO(in1_min, min, 1);
143
+static SENSOR_DEVICE_ATTR_RO(in1_max, max, 1);
144
+static SENSOR_DEVICE_ATTR_RO(in1_label, label, 1);
145
+static SENSOR_DEVICE_ATTR_RO(in2_input, in, 2);
146
+static SENSOR_DEVICE_ATTR_RO(in2_min, min, 2);
147
+static SENSOR_DEVICE_ATTR_RO(in2_max, max, 2);
148
+static SENSOR_DEVICE_ATTR_RO(in2_label, label, 2);
149
+static SENSOR_DEVICE_ATTR_RO(in3_input, in, 3);
150
+static SENSOR_DEVICE_ATTR_RO(in3_min, min, 3);
151
+static SENSOR_DEVICE_ATTR_RO(in3_max, max, 3);
152
+static SENSOR_DEVICE_ATTR_RO(in3_label, label, 3);
153
+static SENSOR_DEVICE_ATTR_RO(in4_input, in, 4);
154
+static SENSOR_DEVICE_ATTR_RO(in4_min, min, 4);
155
+static SENSOR_DEVICE_ATTR_RO(in4_max, max, 4);
156
+static SENSOR_DEVICE_ATTR_RO(in4_label, label, 4);
156157
157158 static struct attribute *menf21bmc_hwmon_attrs[] = {
158159 &sensor_dev_attr_in0_input.dev_attr.attr,