hc
2023-12-06 08f87f769b595151be1afeff53e144f543faa614
kernel/drivers/hwmon/abx500.c
....@@ -1,8 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Copyright (C) ST-Ericsson 2010 - 2013
34 * Author: Martin Persson <martin.persson@stericsson.com>
45 * Hongbo Zhang <hongbo.zhang@linaro.org>
5
- * License Terms: GNU General Public License v2
66 *
77 * ABX500 does not provide auto ADC, so to monitor the required temperatures,
88 * a periodic work is used. It is more important to not wake up the CPU than
....@@ -121,7 +121,7 @@
121121 }
122122
123123 /* HWMON sysfs interfaces */
124
-static ssize_t show_name(struct device *dev, struct device_attribute *devattr,
124
+static ssize_t name_show(struct device *dev, struct device_attribute *devattr,
125125 char *buf)
126126 {
127127 struct abx500_temp *data = dev_get_drvdata(dev);
....@@ -129,7 +129,7 @@
129129 return data->ops.show_name(dev, devattr, buf);
130130 }
131131
132
-static ssize_t show_label(struct device *dev,
132
+static ssize_t label_show(struct device *dev,
133133 struct device_attribute *devattr, char *buf)
134134 {
135135 struct abx500_temp *data = dev_get_drvdata(dev);
....@@ -137,7 +137,7 @@
137137 return data->ops.show_label(dev, devattr, buf);
138138 }
139139
140
-static ssize_t show_input(struct device *dev,
140
+static ssize_t input_show(struct device *dev,
141141 struct device_attribute *devattr, char *buf)
142142 {
143143 int ret, temp;
....@@ -153,8 +153,8 @@
153153 }
154154
155155 /* Set functions (RW nodes) */
156
-static ssize_t set_min(struct device *dev, struct device_attribute *devattr,
157
- const char *buf, size_t count)
156
+static ssize_t min_store(struct device *dev, struct device_attribute *devattr,
157
+ const char *buf, size_t count)
158158 {
159159 unsigned long val;
160160 struct abx500_temp *data = dev_get_drvdata(dev);
....@@ -173,8 +173,8 @@
173173 return count;
174174 }
175175
176
-static ssize_t set_max(struct device *dev, struct device_attribute *devattr,
177
- const char *buf, size_t count)
176
+static ssize_t max_store(struct device *dev, struct device_attribute *devattr,
177
+ const char *buf, size_t count)
178178 {
179179 unsigned long val;
180180 struct abx500_temp *data = dev_get_drvdata(dev);
....@@ -193,9 +193,9 @@
193193 return count;
194194 }
195195
196
-static ssize_t set_max_hyst(struct device *dev,
197
- struct device_attribute *devattr,
198
- const char *buf, size_t count)
196
+static ssize_t max_hyst_store(struct device *dev,
197
+ struct device_attribute *devattr,
198
+ const char *buf, size_t count)
199199 {
200200 unsigned long val;
201201 struct abx500_temp *data = dev_get_drvdata(dev);
....@@ -215,8 +215,8 @@
215215 }
216216
217217 /* Show functions (RO nodes) */
218
-static ssize_t show_min(struct device *dev,
219
- struct device_attribute *devattr, char *buf)
218
+static ssize_t min_show(struct device *dev, struct device_attribute *devattr,
219
+ char *buf)
220220 {
221221 struct abx500_temp *data = dev_get_drvdata(dev);
222222 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -224,8 +224,8 @@
224224 return sprintf(buf, "%lu\n", data->min[attr->index]);
225225 }
226226
227
-static ssize_t show_max(struct device *dev,
228
- struct device_attribute *devattr, char *buf)
227
+static ssize_t max_show(struct device *dev, struct device_attribute *devattr,
228
+ char *buf)
229229 {
230230 struct abx500_temp *data = dev_get_drvdata(dev);
231231 struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
....@@ -233,7 +233,7 @@
233233 return sprintf(buf, "%lu\n", data->max[attr->index]);
234234 }
235235
236
-static ssize_t show_max_hyst(struct device *dev,
236
+static ssize_t max_hyst_show(struct device *dev,
237237 struct device_attribute *devattr, char *buf)
238238 {
239239 struct abx500_temp *data = dev_get_drvdata(dev);
....@@ -242,7 +242,7 @@
242242 return sprintf(buf, "%lu\n", data->max_hyst[attr->index]);
243243 }
244244
245
-static ssize_t show_min_alarm(struct device *dev,
245
+static ssize_t min_alarm_show(struct device *dev,
246246 struct device_attribute *devattr, char *buf)
247247 {
248248 struct abx500_temp *data = dev_get_drvdata(dev);
....@@ -251,7 +251,7 @@
251251 return sprintf(buf, "%d\n", data->min_alarm[attr->index]);
252252 }
253253
254
-static ssize_t show_max_alarm(struct device *dev,
254
+static ssize_t max_alarm_show(struct device *dev,
255255 struct device_attribute *devattr, char *buf)
256256 {
257257 struct abx500_temp *data = dev_get_drvdata(dev);
....@@ -273,47 +273,43 @@
273273 }
274274
275275 /* Chip name, required by hwmon */
276
-static SENSOR_DEVICE_ATTR(name, S_IRUGO, show_name, NULL, 0);
276
+static SENSOR_DEVICE_ATTR_RO(name, name, 0);
277277
278278 /* GPADC - SENSOR1 */
279
-static SENSOR_DEVICE_ATTR(temp1_label, S_IRUGO, show_label, NULL, 0);
280
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_input, NULL, 0);
281
-static SENSOR_DEVICE_ATTR(temp1_min, S_IWUSR | S_IRUGO, show_min, set_min, 0);
282
-static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_max, set_max, 0);
283
-static SENSOR_DEVICE_ATTR(temp1_max_hyst, S_IWUSR | S_IRUGO,
284
- show_max_hyst, set_max_hyst, 0);
285
-static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_min_alarm, NULL, 0);
286
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_max_alarm, NULL, 0);
279
+static SENSOR_DEVICE_ATTR_RO(temp1_label, label, 0);
280
+static SENSOR_DEVICE_ATTR_RO(temp1_input, input, 0);
281
+static SENSOR_DEVICE_ATTR_RW(temp1_min, min, 0);
282
+static SENSOR_DEVICE_ATTR_RW(temp1_max, max, 0);
283
+static SENSOR_DEVICE_ATTR_RW(temp1_max_hyst, max_hyst, 0);
284
+static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, min_alarm, 0);
285
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, max_alarm, 0);
287286
288287 /* GPADC - SENSOR2 */
289
-static SENSOR_DEVICE_ATTR(temp2_label, S_IRUGO, show_label, NULL, 1);
290
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_input, NULL, 1);
291
-static SENSOR_DEVICE_ATTR(temp2_min, S_IWUSR | S_IRUGO, show_min, set_min, 1);
292
-static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_max, set_max, 1);
293
-static SENSOR_DEVICE_ATTR(temp2_max_hyst, S_IWUSR | S_IRUGO,
294
- show_max_hyst, set_max_hyst, 1);
295
-static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_min_alarm, NULL, 1);
296
-static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_max_alarm, NULL, 1);
288
+static SENSOR_DEVICE_ATTR_RO(temp2_label, label, 1);
289
+static SENSOR_DEVICE_ATTR_RO(temp2_input, input, 1);
290
+static SENSOR_DEVICE_ATTR_RW(temp2_min, min, 1);
291
+static SENSOR_DEVICE_ATTR_RW(temp2_max, max, 1);
292
+static SENSOR_DEVICE_ATTR_RW(temp2_max_hyst, max_hyst, 1);
293
+static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, min_alarm, 1);
294
+static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, max_alarm, 1);
297295
298296 /* GPADC - SENSOR3 */
299
-static SENSOR_DEVICE_ATTR(temp3_label, S_IRUGO, show_label, NULL, 2);
300
-static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_input, NULL, 2);
301
-static SENSOR_DEVICE_ATTR(temp3_min, S_IWUSR | S_IRUGO, show_min, set_min, 2);
302
-static SENSOR_DEVICE_ATTR(temp3_max, S_IWUSR | S_IRUGO, show_max, set_max, 2);
303
-static SENSOR_DEVICE_ATTR(temp3_max_hyst, S_IWUSR | S_IRUGO,
304
- show_max_hyst, set_max_hyst, 2);
305
-static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_min_alarm, NULL, 2);
306
-static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_max_alarm, NULL, 2);
297
+static SENSOR_DEVICE_ATTR_RO(temp3_label, label, 2);
298
+static SENSOR_DEVICE_ATTR_RO(temp3_input, input, 2);
299
+static SENSOR_DEVICE_ATTR_RW(temp3_min, min, 2);
300
+static SENSOR_DEVICE_ATTR_RW(temp3_max, max, 2);
301
+static SENSOR_DEVICE_ATTR_RW(temp3_max_hyst, max_hyst, 2);
302
+static SENSOR_DEVICE_ATTR_RO(temp3_min_alarm, min_alarm, 2);
303
+static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, max_alarm, 2);
307304
308305 /* GPADC - SENSOR4 */
309
-static SENSOR_DEVICE_ATTR(temp4_label, S_IRUGO, show_label, NULL, 3);
310
-static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_input, NULL, 3);
311
-static SENSOR_DEVICE_ATTR(temp4_min, S_IWUSR | S_IRUGO, show_min, set_min, 3);
312
-static SENSOR_DEVICE_ATTR(temp4_max, S_IWUSR | S_IRUGO, show_max, set_max, 3);
313
-static SENSOR_DEVICE_ATTR(temp4_max_hyst, S_IWUSR | S_IRUGO,
314
- show_max_hyst, set_max_hyst, 3);
315
-static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_min_alarm, NULL, 3);
316
-static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_max_alarm, NULL, 3);
306
+static SENSOR_DEVICE_ATTR_RO(temp4_label, label, 3);
307
+static SENSOR_DEVICE_ATTR_RO(temp4_input, input, 3);
308
+static SENSOR_DEVICE_ATTR_RW(temp4_min, min, 3);
309
+static SENSOR_DEVICE_ATTR_RW(temp4_max, max, 3);
310
+static SENSOR_DEVICE_ATTR_RW(temp4_max_hyst, max_hyst, 3);
311
+static SENSOR_DEVICE_ATTR_RO(temp4_min_alarm, min_alarm, 3);
312
+static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, max_alarm, 3);
317313
318314 static struct attribute *abx500_temp_attributes[] = {
319315 &sensor_dev_attr_name.dev_attr.attr,