hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/iio/adc/ti-adc081c.c
....@@ -1,17 +1,14 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * TI ADC081C/ADC101C/ADC121C 8/10/12-bit ADC driver
34 *
45 * Copyright (C) 2012 Avionic Design GmbH
56 * Copyright (C) 2016 Intel
67 *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
10
- *
118 * Datasheets:
12
- * http://www.ti.com/lit/ds/symlink/adc081c021.pdf
13
- * http://www.ti.com/lit/ds/symlink/adc101c021.pdf
14
- * http://www.ti.com/lit/ds/symlink/adc121c021.pdf
9
+ * https://www.ti.com/lit/ds/symlink/adc081c021.pdf
10
+ * https://www.ti.com/lit/ds/symlink/adc101c021.pdf
11
+ * https://www.ti.com/lit/ds/symlink/adc121c021.pdf
1512 *
1613 * The devices have a very similar interface and differ mostly in the number of
1714 * bits handled. For the 8-bit and 10-bit models the least-significant 4 or 2
....@@ -21,8 +18,8 @@
2118 #include <linux/err.h>
2219 #include <linux/i2c.h>
2320 #include <linux/module.h>
24
-#include <linux/of.h>
25
-#include <linux/acpi.h>
21
+#include <linux/mod_devicetable.h>
22
+#include <linux/property.h>
2623
2724 #include <linux/iio/iio.h>
2825 #include <linux/iio/buffer.h>
....@@ -155,23 +152,16 @@
155152 {
156153 struct iio_dev *iio;
157154 struct adc081c *adc;
158
- struct adcxx1c_model *model;
155
+ const struct adcxx1c_model *model;
159156 int err;
160157
161158 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_WORD_DATA))
162159 return -EOPNOTSUPP;
163160
164
- if (ACPI_COMPANION(&client->dev)) {
165
- const struct acpi_device_id *ad_id;
166
-
167
- ad_id = acpi_match_device(client->dev.driver->acpi_match_table,
168
- &client->dev);
169
- if (!ad_id)
170
- return -ENODEV;
171
- model = &adcxx1c_models[ad_id->driver_data];
172
- } else {
161
+ if (dev_fwnode(&client->dev))
162
+ model = device_get_match_data(&client->dev);
163
+ else
173164 model = &adcxx1c_models[id->driver_data];
174
- }
175165
176166 iio = devm_iio_device_alloc(&client->dev, sizeof(*adc));
177167 if (!iio)
....@@ -189,8 +179,6 @@
189179 if (err < 0)
190180 return err;
191181
192
- iio->dev.parent = &client->dev;
193
- iio->dev.of_node = client->dev.of_node;
194182 iio->name = dev_name(&client->dev);
195183 iio->modes = INDIO_DIRECT_MODE;
196184 iio->info = &adc081c_info;
....@@ -240,31 +228,26 @@
240228 };
241229 MODULE_DEVICE_TABLE(i2c, adc081c_id);
242230
243
-#ifdef CONFIG_OF
244
-static const struct of_device_id adc081c_of_match[] = {
245
- { .compatible = "ti,adc081c" },
246
- { .compatible = "ti,adc101c" },
247
- { .compatible = "ti,adc121c" },
248
- { }
249
-};
250
-MODULE_DEVICE_TABLE(of, adc081c_of_match);
251
-#endif
252
-
253
-#ifdef CONFIG_ACPI
254231 static const struct acpi_device_id adc081c_acpi_match[] = {
255
- { "ADC081C", ADC081C },
256
- { "ADC101C", ADC101C },
257
- { "ADC121C", ADC121C },
232
+ /* Used on some AAEON boards */
233
+ { "ADC081C", (kernel_ulong_t)&adcxx1c_models[ADC081C] },
258234 { }
259235 };
260236 MODULE_DEVICE_TABLE(acpi, adc081c_acpi_match);
261
-#endif
237
+
238
+static const struct of_device_id adc081c_of_match[] = {
239
+ { .compatible = "ti,adc081c", .data = &adcxx1c_models[ADC081C] },
240
+ { .compatible = "ti,adc101c", .data = &adcxx1c_models[ADC101C] },
241
+ { .compatible = "ti,adc121c", .data = &adcxx1c_models[ADC121C] },
242
+ { }
243
+};
244
+MODULE_DEVICE_TABLE(of, adc081c_of_match);
262245
263246 static struct i2c_driver adc081c_driver = {
264247 .driver = {
265248 .name = "adc081c",
266
- .of_match_table = of_match_ptr(adc081c_of_match),
267
- .acpi_match_table = ACPI_PTR(adc081c_acpi_match),
249
+ .of_match_table = adc081c_of_match,
250
+ .acpi_match_table = adc081c_acpi_match,
268251 },
269252 .probe = adc081c_probe,
270253 .remove = adc081c_remove,