hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/gl518sm.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * gl518sm.c - Part of lm_sensors, Linux kernel modules for hardware
34 * monitoring
....@@ -5,20 +6,6 @@
56 * Kyosti Malkki <kmalkki@cc.hut.fi>
67 * Copyright (C) 2004 Hong-Gunn Chew <hglinux@gunnet.org> and
78 * Jean Delvare <jdelvare@suse.de>
8
- *
9
- * This program is free software; you can redistribute it and/or modify
10
- * it under the terms of the GNU General Public License as published by
11
- * the Free Software Foundation; either version 2 of the License, or
12
- * (at your option) any later version.
13
- *
14
- * This program is distributed in the hope that it will be useful,
15
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
- * GNU General Public License for more details.
18
- *
19
- * You should have received a copy of the GNU General Public License
20
- * along with this program; if not, write to the Free Software
21
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
229 *
2310 * Ported to Linux 2.6 by Hong-Gunn Chew with the help of Jean Delvare
2411 * and advice of Greg Kroah-Hartman.
....@@ -264,7 +251,7 @@
264251 show(BOOL, beep_enable, beep_enable);
265252 show(BEEP_MASK, beep_mask, beep_mask);
266253
267
-static ssize_t show_fan_input(struct device *dev,
254
+static ssize_t fan_input_show(struct device *dev,
268255 struct device_attribute *attr, char *buf)
269256 {
270257 int nr = to_sensor_dev_attr(attr)->index;
....@@ -273,8 +260,8 @@
273260 DIV_FROM_REG(data->fan_div[nr])));
274261 }
275262
276
-static ssize_t show_fan_min(struct device *dev,
277
- struct device_attribute *attr, char *buf)
263
+static ssize_t fan_min_show(struct device *dev, struct device_attribute *attr,
264
+ char *buf)
278265 {
279266 int nr = to_sensor_dev_attr(attr)->index;
280267 struct gl518_data *data = gl518_update_device(dev);
....@@ -282,8 +269,8 @@
282269 DIV_FROM_REG(data->fan_div[nr])));
283270 }
284271
285
-static ssize_t show_fan_div(struct device *dev,
286
- struct device_attribute *attr, char *buf)
272
+static ssize_t fan_div_show(struct device *dev, struct device_attribute *attr,
273
+ char *buf)
287274 {
288275 int nr = to_sensor_dev_attr(attr)->index;
289276 struct gl518_data *data = gl518_update_device(dev);
....@@ -350,8 +337,9 @@
350337 set_bits(BOOL, beep_enable, beep_enable, GL518_REG_CONF, 0x04, 2);
351338 set(BEEP_MASK, beep_mask, beep_mask, GL518_REG_ALARM);
352339
353
-static ssize_t set_fan_min(struct device *dev, struct device_attribute *attr,
354
- const char *buf, size_t count)
340
+static ssize_t fan_min_store(struct device *dev,
341
+ struct device_attribute *attr, const char *buf,
342
+ size_t count)
355343 {
356344 struct gl518_data *data = dev_get_drvdata(dev);
357345 struct i2c_client *client = data->client;
....@@ -383,8 +371,9 @@
383371 return count;
384372 }
385373
386
-static ssize_t set_fan_div(struct device *dev, struct device_attribute *attr,
387
- const char *buf, size_t count)
374
+static ssize_t fan_div_store(struct device *dev,
375
+ struct device_attribute *attr, const char *buf,
376
+ size_t count)
388377 {
389378 struct gl518_data *data = dev_get_drvdata(dev);
390379 struct i2c_client *client = data->client;
....@@ -427,40 +416,36 @@
427416 return count;
428417 }
429418
430
-static DEVICE_ATTR(temp1_input, S_IRUGO, show_temp_input1, NULL);
431
-static DEVICE_ATTR(temp1_max, S_IWUSR|S_IRUGO, show_temp_max1, set_temp_max1);
432
-static DEVICE_ATTR(temp1_max_hyst, S_IWUSR|S_IRUGO,
433
- show_temp_hyst1, set_temp_hyst1);
434
-static DEVICE_ATTR(fan1_auto, S_IWUSR|S_IRUGO, show_fan_auto1, set_fan_auto1);
435
-static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_fan_input, NULL, 0);
436
-static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_fan_input, NULL, 1);
437
-static SENSOR_DEVICE_ATTR(fan1_min, S_IWUSR|S_IRUGO,
438
- show_fan_min, set_fan_min, 0);
439
-static SENSOR_DEVICE_ATTR(fan2_min, S_IWUSR|S_IRUGO,
440
- show_fan_min, set_fan_min, 1);
441
-static SENSOR_DEVICE_ATTR(fan1_div, S_IWUSR|S_IRUGO,
442
- show_fan_div, set_fan_div, 0);
443
-static SENSOR_DEVICE_ATTR(fan2_div, S_IWUSR|S_IRUGO,
444
- show_fan_div, set_fan_div, 1);
445
-static DEVICE_ATTR(in0_input, S_IRUGO, show_in_input0, NULL);
446
-static DEVICE_ATTR(in1_input, S_IRUGO, show_in_input1, NULL);
447
-static DEVICE_ATTR(in2_input, S_IRUGO, show_in_input2, NULL);
448
-static DEVICE_ATTR(in3_input, S_IRUGO, show_in_input3, NULL);
449
-static DEVICE_ATTR(in0_min, S_IWUSR|S_IRUGO, show_in_min0, set_in_min0);
450
-static DEVICE_ATTR(in1_min, S_IWUSR|S_IRUGO, show_in_min1, set_in_min1);
451
-static DEVICE_ATTR(in2_min, S_IWUSR|S_IRUGO, show_in_min2, set_in_min2);
452
-static DEVICE_ATTR(in3_min, S_IWUSR|S_IRUGO, show_in_min3, set_in_min3);
453
-static DEVICE_ATTR(in0_max, S_IWUSR|S_IRUGO, show_in_max0, set_in_max0);
454
-static DEVICE_ATTR(in1_max, S_IWUSR|S_IRUGO, show_in_max1, set_in_max1);
455
-static DEVICE_ATTR(in2_max, S_IWUSR|S_IRUGO, show_in_max2, set_in_max2);
456
-static DEVICE_ATTR(in3_max, S_IWUSR|S_IRUGO, show_in_max3, set_in_max3);
457
-static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
458
-static DEVICE_ATTR(beep_enable, S_IWUSR|S_IRUGO,
459
- show_beep_enable, set_beep_enable);
460
-static DEVICE_ATTR(beep_mask, S_IWUSR|S_IRUGO,
461
- show_beep_mask, set_beep_mask);
419
+static DEVICE_ATTR(temp1_input, 0444, show_temp_input1, NULL);
420
+static DEVICE_ATTR(temp1_max, 0644, show_temp_max1, set_temp_max1);
421
+static DEVICE_ATTR(temp1_max_hyst, 0644,
422
+ show_temp_hyst1, set_temp_hyst1);
423
+static DEVICE_ATTR(fan1_auto, 0644, show_fan_auto1, set_fan_auto1);
424
+static SENSOR_DEVICE_ATTR_RO(fan1_input, fan_input, 0);
425
+static SENSOR_DEVICE_ATTR_RO(fan2_input, fan_input, 1);
426
+static SENSOR_DEVICE_ATTR_RW(fan1_min, fan_min, 0);
427
+static SENSOR_DEVICE_ATTR_RW(fan2_min, fan_min, 1);
428
+static SENSOR_DEVICE_ATTR_RW(fan1_div, fan_div, 0);
429
+static SENSOR_DEVICE_ATTR_RW(fan2_div, fan_div, 1);
430
+static DEVICE_ATTR(in0_input, 0444, show_in_input0, NULL);
431
+static DEVICE_ATTR(in1_input, 0444, show_in_input1, NULL);
432
+static DEVICE_ATTR(in2_input, 0444, show_in_input2, NULL);
433
+static DEVICE_ATTR(in3_input, 0444, show_in_input3, NULL);
434
+static DEVICE_ATTR(in0_min, 0644, show_in_min0, set_in_min0);
435
+static DEVICE_ATTR(in1_min, 0644, show_in_min1, set_in_min1);
436
+static DEVICE_ATTR(in2_min, 0644, show_in_min2, set_in_min2);
437
+static DEVICE_ATTR(in3_min, 0644, show_in_min3, set_in_min3);
438
+static DEVICE_ATTR(in0_max, 0644, show_in_max0, set_in_max0);
439
+static DEVICE_ATTR(in1_max, 0644, show_in_max1, set_in_max1);
440
+static DEVICE_ATTR(in2_max, 0644, show_in_max2, set_in_max2);
441
+static DEVICE_ATTR(in3_max, 0644, show_in_max3, set_in_max3);
442
+static DEVICE_ATTR(alarms, 0444, show_alarms, NULL);
443
+static DEVICE_ATTR(beep_enable, 0644,
444
+ show_beep_enable, set_beep_enable);
445
+static DEVICE_ATTR(beep_mask, 0644,
446
+ show_beep_mask, set_beep_mask);
462447
463
-static ssize_t show_alarm(struct device *dev, struct device_attribute *attr,
448
+static ssize_t alarm_show(struct device *dev, struct device_attribute *attr,
464449 char *buf)
465450 {
466451 int bitnr = to_sensor_dev_attr(attr)->index;
....@@ -468,24 +453,24 @@
468453 return sprintf(buf, "%u\n", (data->alarms >> bitnr) & 1);
469454 }
470455
471
-static SENSOR_DEVICE_ATTR(in0_alarm, S_IRUGO, show_alarm, NULL, 0);
472
-static SENSOR_DEVICE_ATTR(in1_alarm, S_IRUGO, show_alarm, NULL, 1);
473
-static SENSOR_DEVICE_ATTR(in2_alarm, S_IRUGO, show_alarm, NULL, 2);
474
-static SENSOR_DEVICE_ATTR(in3_alarm, S_IRUGO, show_alarm, NULL, 3);
475
-static SENSOR_DEVICE_ATTR(temp1_alarm, S_IRUGO, show_alarm, NULL, 4);
476
-static SENSOR_DEVICE_ATTR(fan1_alarm, S_IRUGO, show_alarm, NULL, 5);
477
-static SENSOR_DEVICE_ATTR(fan2_alarm, S_IRUGO, show_alarm, NULL, 6);
456
+static SENSOR_DEVICE_ATTR_RO(in0_alarm, alarm, 0);
457
+static SENSOR_DEVICE_ATTR_RO(in1_alarm, alarm, 1);
458
+static SENSOR_DEVICE_ATTR_RO(in2_alarm, alarm, 2);
459
+static SENSOR_DEVICE_ATTR_RO(in3_alarm, alarm, 3);
460
+static SENSOR_DEVICE_ATTR_RO(temp1_alarm, alarm, 4);
461
+static SENSOR_DEVICE_ATTR_RO(fan1_alarm, alarm, 5);
462
+static SENSOR_DEVICE_ATTR_RO(fan2_alarm, alarm, 6);
478463
479
-static ssize_t show_beep(struct device *dev, struct device_attribute *attr,
480
- char *buf)
464
+static ssize_t beep_show(struct device *dev, struct device_attribute *attr,
465
+ char *buf)
481466 {
482467 int bitnr = to_sensor_dev_attr(attr)->index;
483468 struct gl518_data *data = gl518_update_device(dev);
484469 return sprintf(buf, "%u\n", (data->beep_mask >> bitnr) & 1);
485470 }
486471
487
-static ssize_t set_beep(struct device *dev, struct device_attribute *attr,
488
- const char *buf, size_t count)
472
+static ssize_t beep_store(struct device *dev, struct device_attribute *attr,
473
+ const char *buf, size_t count)
489474 {
490475 struct gl518_data *data = dev_get_drvdata(dev);
491476 struct i2c_client *client = data->client;
....@@ -511,13 +496,13 @@
511496 return count;
512497 }
513498
514
-static SENSOR_DEVICE_ATTR(in0_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 0);
515
-static SENSOR_DEVICE_ATTR(in1_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 1);
516
-static SENSOR_DEVICE_ATTR(in2_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 2);
517
-static SENSOR_DEVICE_ATTR(in3_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 3);
518
-static SENSOR_DEVICE_ATTR(temp1_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 4);
519
-static SENSOR_DEVICE_ATTR(fan1_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 5);
520
-static SENSOR_DEVICE_ATTR(fan2_beep, S_IRUGO|S_IWUSR, show_beep, set_beep, 6);
499
+static SENSOR_DEVICE_ATTR_RW(in0_beep, beep, 0);
500
+static SENSOR_DEVICE_ATTR_RW(in1_beep, beep, 1);
501
+static SENSOR_DEVICE_ATTR_RW(in2_beep, beep, 2);
502
+static SENSOR_DEVICE_ATTR_RW(in3_beep, beep, 3);
503
+static SENSOR_DEVICE_ATTR_RW(temp1_beep, beep, 4);
504
+static SENSOR_DEVICE_ATTR_RW(fan1_beep, beep, 5);
505
+static SENSOR_DEVICE_ATTR_RW(fan2_beep, beep, 6);
521506
522507 static struct attribute *gl518_attributes[] = {
523508 &dev_attr_in3_input.attr,
....@@ -626,8 +611,7 @@
626611 gl518_write_value(client, GL518_REG_CONF, 0x40 | regvalue);
627612 }
628613
629
-static int gl518_probe(struct i2c_client *client,
630
- const struct i2c_device_id *id)
614
+static int gl518_probe(struct i2c_client *client)
631615 {
632616 struct device *dev = &client->dev;
633617 struct device *hwmon_dev;
....@@ -668,7 +652,7 @@
668652 .driver = {
669653 .name = "gl518sm",
670654 },
671
- .probe = gl518_probe,
655
+ .probe_new = gl518_probe,
672656 .id_table = gl518_id,
673657 .detect = gl518_detect,
674658 .address_list = normal_i2c,