hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/hwmon/emc2103.c
....@@ -1,20 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * emc2103.c - Support for SMSC EMC2103
34 * Copyright (c) 2010 SMSC
4
- *
5
- * This program is free software; you can redistribute it and/or modify
6
- * it under the terms of the GNU General Public License as published by
7
- * the Free Software Foundation; either version 2 of the License, or
8
- * (at your option) any later version.
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
15
- * You should have received a copy of the GNU General Public License
16
- * along with this program; if not, write to the Free Software
17
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
185 */
196
207 #include <linux/module.h>
....@@ -185,7 +172,7 @@
185172 }
186173
187174 static ssize_t
188
-show_temp(struct device *dev, struct device_attribute *da, char *buf)
175
+temp_show(struct device *dev, struct device_attribute *da, char *buf)
189176 {
190177 int nr = to_sensor_dev_attr(da)->index;
191178 struct emc2103_data *data = emc2103_update_device(dev);
....@@ -195,7 +182,7 @@
195182 }
196183
197184 static ssize_t
198
-show_temp_min(struct device *dev, struct device_attribute *da, char *buf)
185
+temp_min_show(struct device *dev, struct device_attribute *da, char *buf)
199186 {
200187 int nr = to_sensor_dev_attr(da)->index;
201188 struct emc2103_data *data = emc2103_update_device(dev);
....@@ -204,7 +191,7 @@
204191 }
205192
206193 static ssize_t
207
-show_temp_max(struct device *dev, struct device_attribute *da, char *buf)
194
+temp_max_show(struct device *dev, struct device_attribute *da, char *buf)
208195 {
209196 int nr = to_sensor_dev_attr(da)->index;
210197 struct emc2103_data *data = emc2103_update_device(dev);
....@@ -213,7 +200,7 @@
213200 }
214201
215202 static ssize_t
216
-show_temp_fault(struct device *dev, struct device_attribute *da, char *buf)
203
+temp_fault_show(struct device *dev, struct device_attribute *da, char *buf)
217204 {
218205 int nr = to_sensor_dev_attr(da)->index;
219206 struct emc2103_data *data = emc2103_update_device(dev);
....@@ -222,7 +209,8 @@
222209 }
223210
224211 static ssize_t
225
-show_temp_min_alarm(struct device *dev, struct device_attribute *da, char *buf)
212
+temp_min_alarm_show(struct device *dev, struct device_attribute *da,
213
+ char *buf)
226214 {
227215 int nr = to_sensor_dev_attr(da)->index;
228216 struct emc2103_data *data = emc2103_update_device(dev);
....@@ -231,7 +219,8 @@
231219 }
232220
233221 static ssize_t
234
-show_temp_max_alarm(struct device *dev, struct device_attribute *da, char *buf)
222
+temp_max_alarm_show(struct device *dev, struct device_attribute *da,
223
+ char *buf)
235224 {
236225 int nr = to_sensor_dev_attr(da)->index;
237226 struct emc2103_data *data = emc2103_update_device(dev);
....@@ -239,8 +228,8 @@
239228 return sprintf(buf, "%d\n", alarm ? 1 : 0);
240229 }
241230
242
-static ssize_t set_temp_min(struct device *dev, struct device_attribute *da,
243
- const char *buf, size_t count)
231
+static ssize_t temp_min_store(struct device *dev, struct device_attribute *da,
232
+ const char *buf, size_t count)
244233 {
245234 int nr = to_sensor_dev_attr(da)->index;
246235 struct emc2103_data *data = dev_get_drvdata(dev);
....@@ -261,8 +250,8 @@
261250 return count;
262251 }
263252
264
-static ssize_t set_temp_max(struct device *dev, struct device_attribute *da,
265
- const char *buf, size_t count)
253
+static ssize_t temp_max_store(struct device *dev, struct device_attribute *da,
254
+ const char *buf, size_t count)
266255 {
267256 int nr = to_sensor_dev_attr(da)->index;
268257 struct emc2103_data *data = dev_get_drvdata(dev);
....@@ -470,49 +459,33 @@
470459 return count;
471460 }
472461
473
-static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_temp, NULL, 0);
474
-static SENSOR_DEVICE_ATTR(temp1_min, S_IRUGO | S_IWUSR, show_temp_min,
475
- set_temp_min, 0);
476
-static SENSOR_DEVICE_ATTR(temp1_max, S_IRUGO | S_IWUSR, show_temp_max,
477
- set_temp_max, 0);
478
-static SENSOR_DEVICE_ATTR(temp1_fault, S_IRUGO, show_temp_fault, NULL, 0);
479
-static SENSOR_DEVICE_ATTR(temp1_min_alarm, S_IRUGO, show_temp_min_alarm,
480
- NULL, 0);
481
-static SENSOR_DEVICE_ATTR(temp1_max_alarm, S_IRUGO, show_temp_max_alarm,
482
- NULL, 0);
462
+static SENSOR_DEVICE_ATTR_RO(temp1_input, temp, 0);
463
+static SENSOR_DEVICE_ATTR_RW(temp1_min, temp_min, 0);
464
+static SENSOR_DEVICE_ATTR_RW(temp1_max, temp_max, 0);
465
+static SENSOR_DEVICE_ATTR_RO(temp1_fault, temp_fault, 0);
466
+static SENSOR_DEVICE_ATTR_RO(temp1_min_alarm, temp_min_alarm, 0);
467
+static SENSOR_DEVICE_ATTR_RO(temp1_max_alarm, temp_max_alarm, 0);
483468
484
-static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_temp, NULL, 1);
485
-static SENSOR_DEVICE_ATTR(temp2_min, S_IRUGO | S_IWUSR, show_temp_min,
486
- set_temp_min, 1);
487
-static SENSOR_DEVICE_ATTR(temp2_max, S_IRUGO | S_IWUSR, show_temp_max,
488
- set_temp_max, 1);
489
-static SENSOR_DEVICE_ATTR(temp2_fault, S_IRUGO, show_temp_fault, NULL, 1);
490
-static SENSOR_DEVICE_ATTR(temp2_min_alarm, S_IRUGO, show_temp_min_alarm,
491
- NULL, 1);
492
-static SENSOR_DEVICE_ATTR(temp2_max_alarm, S_IRUGO, show_temp_max_alarm,
493
- NULL, 1);
469
+static SENSOR_DEVICE_ATTR_RO(temp2_input, temp, 1);
470
+static SENSOR_DEVICE_ATTR_RW(temp2_min, temp_min, 1);
471
+static SENSOR_DEVICE_ATTR_RW(temp2_max, temp_max, 1);
472
+static SENSOR_DEVICE_ATTR_RO(temp2_fault, temp_fault, 1);
473
+static SENSOR_DEVICE_ATTR_RO(temp2_min_alarm, temp_min_alarm, 1);
474
+static SENSOR_DEVICE_ATTR_RO(temp2_max_alarm, temp_max_alarm, 1);
494475
495
-static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_temp, NULL, 2);
496
-static SENSOR_DEVICE_ATTR(temp3_min, S_IRUGO | S_IWUSR, show_temp_min,
497
- set_temp_min, 2);
498
-static SENSOR_DEVICE_ATTR(temp3_max, S_IRUGO | S_IWUSR, show_temp_max,
499
- set_temp_max, 2);
500
-static SENSOR_DEVICE_ATTR(temp3_fault, S_IRUGO, show_temp_fault, NULL, 2);
501
-static SENSOR_DEVICE_ATTR(temp3_min_alarm, S_IRUGO, show_temp_min_alarm,
502
- NULL, 2);
503
-static SENSOR_DEVICE_ATTR(temp3_max_alarm, S_IRUGO, show_temp_max_alarm,
504
- NULL, 2);
476
+static SENSOR_DEVICE_ATTR_RO(temp3_input, temp, 2);
477
+static SENSOR_DEVICE_ATTR_RW(temp3_min, temp_min, 2);
478
+static SENSOR_DEVICE_ATTR_RW(temp3_max, temp_max, 2);
479
+static SENSOR_DEVICE_ATTR_RO(temp3_fault, temp_fault, 2);
480
+static SENSOR_DEVICE_ATTR_RO(temp3_min_alarm, temp_min_alarm, 2);
481
+static SENSOR_DEVICE_ATTR_RO(temp3_max_alarm, temp_max_alarm, 2);
505482
506
-static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_temp, NULL, 3);
507
-static SENSOR_DEVICE_ATTR(temp4_min, S_IRUGO | S_IWUSR, show_temp_min,
508
- set_temp_min, 3);
509
-static SENSOR_DEVICE_ATTR(temp4_max, S_IRUGO | S_IWUSR, show_temp_max,
510
- set_temp_max, 3);
511
-static SENSOR_DEVICE_ATTR(temp4_fault, S_IRUGO, show_temp_fault, NULL, 3);
512
-static SENSOR_DEVICE_ATTR(temp4_min_alarm, S_IRUGO, show_temp_min_alarm,
513
- NULL, 3);
514
-static SENSOR_DEVICE_ATTR(temp4_max_alarm, S_IRUGO, show_temp_max_alarm,
515
- NULL, 3);
483
+static SENSOR_DEVICE_ATTR_RO(temp4_input, temp, 3);
484
+static SENSOR_DEVICE_ATTR_RW(temp4_min, temp_min, 3);
485
+static SENSOR_DEVICE_ATTR_RW(temp4_max, temp_max, 3);
486
+static SENSOR_DEVICE_ATTR_RO(temp4_fault, temp_fault, 3);
487
+static SENSOR_DEVICE_ATTR_RO(temp4_min_alarm, temp_min_alarm, 3);
488
+static SENSOR_DEVICE_ATTR_RO(temp4_max_alarm, temp_max_alarm, 3);
516489
517490 static DEVICE_ATTR_RO(fan1_input);
518491 static DEVICE_ATTR_RW(fan1_div);
....@@ -578,7 +551,7 @@
578551 };
579552
580553 static int
581
-emc2103_probe(struct i2c_client *client, const struct i2c_device_id *id)
554
+emc2103_probe(struct i2c_client *client)
582555 {
583556 struct emc2103_data *data;
584557 struct device *hwmon_dev;
....@@ -680,7 +653,7 @@
680653 .driver = {
681654 .name = "emc2103",
682655 },
683
- .probe = emc2103_probe,
656
+ .probe_new = emc2103_probe,
684657 .id_table = emc2103_ids,
685658 .detect = emc2103_detect,
686659 .address_list = normal_i2c,