hc
2024-05-10 37f49e37ab4cb5d0bc4c60eb5c6d4dd57db767bb
kernel/drivers/hwmon/ads7828.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * ads7828.c - driver for TI ADS7828 8-channel A/D converter and compatibles
34 * (C) 2007 EADS Astrium
....@@ -8,21 +9,7 @@
89 *
910 * ADS7830 support, by Guillaume Roguez <guillaume.roguez@savoirfairelinux.com>
1011 *
11
- * For further information, see the Documentation/hwmon/ads7828 file.
12
- *
13
- * This program is free software; you can redistribute it and/or modify
14
- * it under the terms of the GNU General Public License as published by
15
- * the Free Software Foundation; either version 2 of the License, or
16
- * (at your option) any later version.
17
- *
18
- * This program is distributed in the hope that it will be useful,
19
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
- * GNU General Public License for more details.
22
- *
23
- * You should have received a copy of the GNU General Public License
24
- * along with this program; if not, write to the Free Software
25
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
12
+ * For further information, see the Documentation/hwmon/ads7828.rst file.
2613 */
2714
2815 #include <linux/err.h>
....@@ -62,8 +49,8 @@
6249 }
6350
6451 /* sysfs callback function */
65
-static ssize_t ads7828_show_in(struct device *dev, struct device_attribute *da,
66
- char *buf)
52
+static ssize_t ads7828_in_show(struct device *dev,
53
+ struct device_attribute *da, char *buf)
6754 {
6855 struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
6956 struct ads7828_data *data = dev_get_drvdata(dev);
....@@ -79,14 +66,14 @@
7966 DIV_ROUND_CLOSEST(regval * data->lsb_resol, 1000));
8067 }
8168
82
-static SENSOR_DEVICE_ATTR(in0_input, S_IRUGO, ads7828_show_in, NULL, 0);
83
-static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, ads7828_show_in, NULL, 1);
84
-static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, ads7828_show_in, NULL, 2);
85
-static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, ads7828_show_in, NULL, 3);
86
-static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, ads7828_show_in, NULL, 4);
87
-static SENSOR_DEVICE_ATTR(in5_input, S_IRUGO, ads7828_show_in, NULL, 5);
88
-static SENSOR_DEVICE_ATTR(in6_input, S_IRUGO, ads7828_show_in, NULL, 6);
89
-static SENSOR_DEVICE_ATTR(in7_input, S_IRUGO, ads7828_show_in, NULL, 7);
69
+static SENSOR_DEVICE_ATTR_RO(in0_input, ads7828_in, 0);
70
+static SENSOR_DEVICE_ATTR_RO(in1_input, ads7828_in, 1);
71
+static SENSOR_DEVICE_ATTR_RO(in2_input, ads7828_in, 2);
72
+static SENSOR_DEVICE_ATTR_RO(in3_input, ads7828_in, 3);
73
+static SENSOR_DEVICE_ATTR_RO(in4_input, ads7828_in, 4);
74
+static SENSOR_DEVICE_ATTR_RO(in5_input, ads7828_in, 5);
75
+static SENSOR_DEVICE_ATTR_RO(in6_input, ads7828_in, 6);
76
+static SENSOR_DEVICE_ATTR_RO(in7_input, ads7828_in, 7);
9077
9178 static struct attribute *ads7828_attrs[] = {
9279 &sensor_dev_attr_in0_input.dev_attr.attr,
....@@ -112,8 +99,9 @@
11299 .val_bits = 8,
113100 };
114101
115
-static int ads7828_probe(struct i2c_client *client,
116
- const struct i2c_device_id *id)
102
+static const struct i2c_device_id ads7828_device_ids[];
103
+
104
+static int ads7828_probe(struct i2c_client *client)
117105 {
118106 struct device *dev = &client->dev;
119107 struct ads7828_platform_data *pdata = dev_get_platdata(dev);
....@@ -154,7 +142,7 @@
154142 chip = (enum ads7828_chips)
155143 of_device_get_match_data(&client->dev);
156144 else
157
- chip = id->driver_data;
145
+ chip = i2c_match_id(ads7828_device_ids, client)->driver_data;
158146
159147 /* Bound Vref with min/max values */
160148 vref_mv = clamp_val(vref_mv, ADS7828_EXT_VREF_MV_MIN,
....@@ -200,7 +188,7 @@
200188 };
201189 MODULE_DEVICE_TABLE(i2c, ads7828_device_ids);
202190
203
-static const struct of_device_id ads7828_of_match[] = {
191
+static const struct of_device_id __maybe_unused ads7828_of_match[] = {
204192 {
205193 .compatible = "ti,ads7828",
206194 .data = (void *)ads7828
....@@ -220,7 +208,7 @@
220208 },
221209
222210 .id_table = ads7828_device_ids,
223
- .probe = ads7828_probe,
211
+ .probe_new = ads7828_probe,
224212 };
225213
226214 module_i2c_driver(ads7828_driver);