.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * ads7828.c - driver for TI ADS7828 8-channel A/D converter and compatibles |
---|
3 | 4 | * (C) 2007 EADS Astrium |
---|
.. | .. |
---|
8 | 9 | * |
---|
9 | 10 | * ADS7830 support, by Guillaume Roguez <guillaume.roguez@savoirfairelinux.com> |
---|
10 | 11 | * |
---|
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. |
---|
26 | 13 | */ |
---|
27 | 14 | |
---|
28 | 15 | #include <linux/err.h> |
---|
.. | .. |
---|
62 | 49 | } |
---|
63 | 50 | |
---|
64 | 51 | /* 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) |
---|
67 | 54 | { |
---|
68 | 55 | struct sensor_device_attribute *attr = to_sensor_dev_attr(da); |
---|
69 | 56 | struct ads7828_data *data = dev_get_drvdata(dev); |
---|
.. | .. |
---|
79 | 66 | DIV_ROUND_CLOSEST(regval * data->lsb_resol, 1000)); |
---|
80 | 67 | } |
---|
81 | 68 | |
---|
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); |
---|
90 | 77 | |
---|
91 | 78 | static struct attribute *ads7828_attrs[] = { |
---|
92 | 79 | &sensor_dev_attr_in0_input.dev_attr.attr, |
---|
.. | .. |
---|
112 | 99 | .val_bits = 8, |
---|
113 | 100 | }; |
---|
114 | 101 | |
---|
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) |
---|
117 | 105 | { |
---|
118 | 106 | struct device *dev = &client->dev; |
---|
119 | 107 | struct ads7828_platform_data *pdata = dev_get_platdata(dev); |
---|
.. | .. |
---|
154 | 142 | chip = (enum ads7828_chips) |
---|
155 | 143 | of_device_get_match_data(&client->dev); |
---|
156 | 144 | else |
---|
157 | | - chip = id->driver_data; |
---|
| 145 | + chip = i2c_match_id(ads7828_device_ids, client)->driver_data; |
---|
158 | 146 | |
---|
159 | 147 | /* Bound Vref with min/max values */ |
---|
160 | 148 | vref_mv = clamp_val(vref_mv, ADS7828_EXT_VREF_MV_MIN, |
---|
.. | .. |
---|
200 | 188 | }; |
---|
201 | 189 | MODULE_DEVICE_TABLE(i2c, ads7828_device_ids); |
---|
202 | 190 | |
---|
203 | | -static const struct of_device_id ads7828_of_match[] = { |
---|
| 191 | +static const struct of_device_id __maybe_unused ads7828_of_match[] = { |
---|
204 | 192 | { |
---|
205 | 193 | .compatible = "ti,ads7828", |
---|
206 | 194 | .data = (void *)ads7828 |
---|
.. | .. |
---|
220 | 208 | }, |
---|
221 | 209 | |
---|
222 | 210 | .id_table = ads7828_device_ids, |
---|
223 | | - .probe = ads7828_probe, |
---|
| 211 | + .probe_new = ads7828_probe, |
---|
224 | 212 | }; |
---|
225 | 213 | |
---|
226 | 214 | module_i2c_driver(ads7828_driver); |
---|