hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/max6639.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * max6639.c - Support for Maxim MAX6639
34 *
....@@ -7,20 +8,6 @@
78 *
89 * based on the initial MAX6639 support from semptian.net
910 * by He Changqing <hechangqing@semptian.com>
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 #include <linux/module.h>
....@@ -162,7 +149,7 @@
162149 return ret;
163150 }
164151
165
-static ssize_t show_temp_input(struct device *dev,
152
+static ssize_t temp_input_show(struct device *dev,
166153 struct device_attribute *dev_attr, char *buf)
167154 {
168155 long temp;
....@@ -176,7 +163,7 @@
176163 return sprintf(buf, "%ld\n", temp);
177164 }
178165
179
-static ssize_t show_temp_fault(struct device *dev,
166
+static ssize_t temp_fault_show(struct device *dev,
180167 struct device_attribute *dev_attr, char *buf)
181168 {
182169 struct max6639_data *data = max6639_update_device(dev);
....@@ -188,7 +175,7 @@
188175 return sprintf(buf, "%d\n", data->temp_fault[attr->index]);
189176 }
190177
191
-static ssize_t show_temp_max(struct device *dev,
178
+static ssize_t temp_max_show(struct device *dev,
192179 struct device_attribute *dev_attr, char *buf)
193180 {
194181 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
....@@ -197,9 +184,9 @@
197184 return sprintf(buf, "%d\n", (data->temp_therm[attr->index] * 1000));
198185 }
199186
200
-static ssize_t set_temp_max(struct device *dev,
201
- struct device_attribute *dev_attr,
202
- const char *buf, size_t count)
187
+static ssize_t temp_max_store(struct device *dev,
188
+ struct device_attribute *dev_attr,
189
+ const char *buf, size_t count)
203190 {
204191 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
205192 struct max6639_data *data = dev_get_drvdata(dev);
....@@ -220,7 +207,7 @@
220207 return count;
221208 }
222209
223
-static ssize_t show_temp_crit(struct device *dev,
210
+static ssize_t temp_crit_show(struct device *dev,
224211 struct device_attribute *dev_attr, char *buf)
225212 {
226213 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
....@@ -229,9 +216,9 @@
229216 return sprintf(buf, "%d\n", (data->temp_alert[attr->index] * 1000));
230217 }
231218
232
-static ssize_t set_temp_crit(struct device *dev,
233
- struct device_attribute *dev_attr,
234
- const char *buf, size_t count)
219
+static ssize_t temp_crit_store(struct device *dev,
220
+ struct device_attribute *dev_attr,
221
+ const char *buf, size_t count)
235222 {
236223 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
237224 struct max6639_data *data = dev_get_drvdata(dev);
....@@ -252,7 +239,7 @@
252239 return count;
253240 }
254241
255
-static ssize_t show_temp_emergency(struct device *dev,
242
+static ssize_t temp_emergency_show(struct device *dev,
256243 struct device_attribute *dev_attr,
257244 char *buf)
258245 {
....@@ -262,9 +249,9 @@
262249 return sprintf(buf, "%d\n", (data->temp_ot[attr->index] * 1000));
263250 }
264251
265
-static ssize_t set_temp_emergency(struct device *dev,
266
- struct device_attribute *dev_attr,
267
- const char *buf, size_t count)
252
+static ssize_t temp_emergency_store(struct device *dev,
253
+ struct device_attribute *dev_attr,
254
+ const char *buf, size_t count)
268255 {
269256 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
270257 struct max6639_data *data = dev_get_drvdata(dev);
....@@ -285,8 +272,8 @@
285272 return count;
286273 }
287274
288
-static ssize_t show_pwm(struct device *dev,
289
- struct device_attribute *dev_attr, char *buf)
275
+static ssize_t pwm_show(struct device *dev, struct device_attribute *dev_attr,
276
+ char *buf)
290277 {
291278 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
292279 struct max6639_data *data = dev_get_drvdata(dev);
....@@ -294,9 +281,9 @@
294281 return sprintf(buf, "%d\n", data->pwm[attr->index] * 255 / 120);
295282 }
296283
297
-static ssize_t set_pwm(struct device *dev,
298
- struct device_attribute *dev_attr,
299
- const char *buf, size_t count)
284
+static ssize_t pwm_store(struct device *dev,
285
+ struct device_attribute *dev_attr, const char *buf,
286
+ size_t count)
300287 {
301288 struct sensor_device_attribute *attr = to_sensor_dev_attr(dev_attr);
302289 struct max6639_data *data = dev_get_drvdata(dev);
....@@ -319,7 +306,7 @@
319306 return count;
320307 }
321308
322
-static ssize_t show_fan_input(struct device *dev,
309
+static ssize_t fan_input_show(struct device *dev,
323310 struct device_attribute *dev_attr, char *buf)
324311 {
325312 struct max6639_data *data = max6639_update_device(dev);
....@@ -332,7 +319,7 @@
332319 data->rpm_range));
333320 }
334321
335
-static ssize_t show_alarm(struct device *dev,
322
+static ssize_t alarm_show(struct device *dev,
336323 struct device_attribute *dev_attr, char *buf)
337324 {
338325 struct max6639_data *data = max6639_update_device(dev);
....@@ -344,34 +331,28 @@
344331 return sprintf(buf, "%d\n", !!(data->status & (1 << attr->index)));
345332 }
346333
347
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input, NULL, 0);
348
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp_input, NULL, 1);
349
-static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0);
350
-static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1);
351
-static SENSOR_DEVICE_ATTR(temp1_max, S_IWUSR | S_IRUGO, show_temp_max,
352
- set_temp_max, 0);
353
-static SENSOR_DEVICE_ATTR(temp2_max, S_IWUSR | S_IRUGO, show_temp_max,
354
- set_temp_max, 1);
355
-static SENSOR_DEVICE_ATTR(temp1_crit, S_IWUSR | S_IRUGO, show_temp_crit,
356
- set_temp_crit, 0);
357
-static SENSOR_DEVICE_ATTR(temp2_crit, S_IWUSR | S_IRUGO, show_temp_crit,
358
- set_temp_crit, 1);
359
-static SENSOR_DEVICE_ATTR(temp1_emergency, S_IWUSR | S_IRUGO,
360
- show_temp_emergency, set_temp_emergency, 0);
361
-static SENSOR_DEVICE_ATTR(temp2_emergency, S_IWUSR | S_IRUGO,
362
- show_temp_emergency, set_temp_emergency, 1);
363
-static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 0);
364
-static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR | S_IRUGO, show_pwm, set_pwm, 1);
365
-static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0);
366
-static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1);
367
-static SENSOR_DEVICE_ATTR(fan1_fault, S_IRUGO, show_alarm, NULL, 1);
368
-static SENSOR_DEVICE_ATTR(fan2_fault, S_IRUGO, show_alarm, NULL, 0);
369
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_alarm, NULL, 3);
370
-static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_alarm, NULL, 2);
371
-static SENSOR_DEVICE_ATTR(temp1_crit_alarm, S_IRUGO, show_alarm, NULL, 7);
372
-static SENSOR_DEVICE_ATTR(temp2_crit_alarm, S_IRUGO, show_alarm, NULL, 6);
373
-static SENSOR_DEVICE_ATTR(temp1_emergency_alarm, S_IRUGO, show_alarm, NULL, 5);
374
-static SENSOR_DEVICE_ATTR(temp2_emergency_alarm, S_IRUGO, show_alarm, NULL, 4);
334
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp_input, 0);
335
+static SENSOR_DEVICE_ATTR_RO(temp2_input, temp_input, 1);
336
+static SENSOR_DEVICE_ATTR_RO(temp1_fault, temp_fault, 0);
337
+static SENSOR_DEVICE_ATTR_RO(temp2_fault, temp_fault, 1);
338
+static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0);
339
+static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1);
340
+static SENSOR_DEVICE_ATTR_RW(temp1_crit, temp_crit, 0);
341
+static SENSOR_DEVICE_ATTR_RW(temp2_crit, temp_crit, 1);
342
+static SENSOR_DEVICE_ATTR_RW(temp1_emergency, temp_emergency, 0);
343
+static SENSOR_DEVICE_ATTR_RW(temp2_emergency, temp_emergency, 1);
344
+static SENSOR_DEVICE_ATTR_RW(pwm1, pwm, 0);
345
+static SENSOR_DEVICE_ATTR_RW(pwm2, pwm, 1);
346
+static SENSOR_DEVICE_ATTR_RO(fan1_input, fan_input, 0);
347
+static SENSOR_DEVICE_ATTR_RO(fan2_input, fan_input, 1);
348
+static SENSOR_DEVICE_ATTR_RO(fan1_fault, alarm, 1);
349
+static SENSOR_DEVICE_ATTR_RO(fan2_fault, alarm, 0);
350
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, alarm, 3);
351
+static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, alarm, 2);
352
+static SENSOR_DEVICE_ATTR_RO(temp1_crit_alarm, alarm, 7);
353
+static SENSOR_DEVICE_ATTR_RO(temp2_crit_alarm, alarm, 6);
354
+static SENSOR_DEVICE_ATTR_RO(temp1_emergency_alarm, alarm, 5);
355
+static SENSOR_DEVICE_ATTR_RO(temp2_emergency_alarm, alarm, 4);
375356
376357
377358 static struct attribute *max6639_attrs[] = {
....@@ -535,8 +516,7 @@
535516 return 0;
536517 }
537518
538
-static int max6639_probe(struct i2c_client *client,
539
- const struct i2c_device_id *id)
519
+static int max6639_probe(struct i2c_client *client)
540520 {
541521 struct device *dev = &client->dev;
542522 struct max6639_data *data;
....@@ -600,7 +580,7 @@
600580 .name = "max6639",
601581 .pm = &max6639_pm_ops,
602582 },
603
- .probe = max6639_probe,
583
+ .probe_new = max6639_probe,
604584 .id_table = max6639_id,
605585 .detect = max6639_detect,
606586 .address_list = normal_i2c,