forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/iio/potentiometer/max5481.c
....@@ -1,22 +1,17 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 * Maxim Integrated MAX5481-MAX5484 digital potentiometer driver
34 * Copyright 2016 Rockwell Collins
45 *
56 * Datasheet:
6
- * http://datasheets.maximintegrated.com/en/ds/MAX5481-MAX5484.pdf
7
- *
8
- * This program is free software; you can redistribute it and/or modify
9
- * it under the terms of the gnu general public license version 2 as
10
- * published by the free software foundation.
11
- *
7
+ * https://datasheets.maximintegrated.com/en/ds/MAX5481-MAX5484.pdf
128 */
139
14
-#include <linux/acpi.h>
1510 #include <linux/iio/iio.h>
1611 #include <linux/iio/sysfs.h>
1712 #include <linux/module.h>
18
-#include <linux/of.h>
19
-#include <linux/of_device.h>
13
+#include <linux/mod_devicetable.h>
14
+#include <linux/property.h>
2015 #include <linux/spi/spi.h>
2116
2217 /* write wiper reg */
....@@ -121,7 +116,6 @@
121116 .write_raw = max5481_write_raw,
122117 };
123118
124
-#if defined(CONFIG_OF)
125119 static const struct of_device_id max5481_match[] = {
126120 { .compatible = "maxim,max5481", .data = &max5481_cfg[max5481] },
127121 { .compatible = "maxim,max5482", .data = &max5481_cfg[max5482] },
....@@ -130,14 +124,12 @@
130124 { }
131125 };
132126 MODULE_DEVICE_TABLE(of, max5481_match);
133
-#endif
134127
135128 static int max5481_probe(struct spi_device *spi)
136129 {
137130 struct iio_dev *indio_dev;
138131 struct max5481_data *data;
139132 const struct spi_device_id *id = spi_get_device_id(spi);
140
- const struct of_device_id *match;
141133 int ret;
142134
143135 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*data));
....@@ -149,14 +141,11 @@
149141
150142 data->spi = spi;
151143
152
- match = of_match_device(of_match_ptr(max5481_match), &spi->dev);
153
- if (match)
154
- data->cfg = of_device_get_match_data(&spi->dev);
155
- else
144
+ data->cfg = device_get_match_data(&spi->dev);
145
+ if (!data->cfg)
156146 data->cfg = &max5481_cfg[id->driver_data];
157147
158148 indio_dev->name = id->name;
159
- indio_dev->dev.parent = &spi->dev;
160149 indio_dev->modes = INDIO_DIRECT_MODE;
161150
162151 /* variant specific configuration */
....@@ -192,22 +181,10 @@
192181 };
193182 MODULE_DEVICE_TABLE(spi, max5481_id_table);
194183
195
-#if defined(CONFIG_ACPI)
196
-static const struct acpi_device_id max5481_acpi_match[] = {
197
- { "max5481", max5481 },
198
- { "max5482", max5482 },
199
- { "max5483", max5483 },
200
- { "max5484", max5484 },
201
- { }
202
-};
203
-MODULE_DEVICE_TABLE(acpi, max5481_acpi_match);
204
-#endif
205
-
206184 static struct spi_driver max5481_driver = {
207185 .driver = {
208186 .name = "max5481",
209
- .of_match_table = of_match_ptr(max5481_match),
210
- .acpi_match_table = ACPI_PTR(max5481_acpi_match),
187
+ .of_match_table = max5481_match,
211188 },
212189 .probe = max5481_probe,
213190 .remove = max5481_remove,