forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-11 072de836f53be56a70cecf70b43ae43b7ce17376
kernel/drivers/iio/potentiometer/mcp4531.c
....@@ -1,3 +1,4 @@
1
+// SPDX-License-Identifier: GPL-2.0
12 /*
23 * Industrial I/O driver for Microchip digital potentiometers
34 * Copyright (c) 2015 Axentia Technologies AB
....@@ -22,17 +23,13 @@
2223 * mcp4652 2 257 5, 10, 50, 100 01011xx
2324 * mcp4661 2 257 5, 10, 50, 100 0101xxx
2425 * mcp4662 2 257 5, 10, 50, 100 01011xx
25
- *
26
- * This program is free software; you can redistribute it and/or modify it
27
- * under the terms of the GNU General Public License version 2 as published by
28
- * the Free Software Foundation.
2926 */
3027
3128 #include <linux/module.h>
3229 #include <linux/i2c.h>
3330 #include <linux/err.h>
34
-#include <linux/of.h>
35
-#include <linux/of_device.h>
31
+#include <linux/mod_devicetable.h>
32
+#include <linux/property.h>
3633
3734 #include <linux/iio/iio.h>
3835
....@@ -278,8 +275,6 @@
278275 };
279276 MODULE_DEVICE_TABLE(i2c, mcp4531_id);
280277
281
-#ifdef CONFIG_OF
282
-
283278 #define MCP4531_COMPATIBLE(of_compatible, cfg) { \
284279 .compatible = of_compatible, \
285280 .data = &mcp4531_cfg[cfg], \
....@@ -353,14 +348,12 @@
353348 { /* sentinel */ }
354349 };
355350 MODULE_DEVICE_TABLE(of, mcp4531_of_match);
356
-#endif
357351
358352 static int mcp4531_probe(struct i2c_client *client)
359353 {
360354 struct device *dev = &client->dev;
361355 struct mcp4531_data *data;
362356 struct iio_dev *indio_dev;
363
- const struct of_device_id *match;
364357
365358 if (!i2c_check_functionality(client->adapter,
366359 I2C_FUNC_SMBUS_WORD_DATA)) {
....@@ -375,13 +368,10 @@
375368 i2c_set_clientdata(client, indio_dev);
376369 data->client = client;
377370
378
- match = of_match_device(of_match_ptr(mcp4531_of_match), dev);
379
- if (match)
380
- data->cfg = of_device_get_match_data(dev);
381
- else
371
+ data->cfg = device_get_match_data(dev);
372
+ if (!data->cfg)
382373 data->cfg = &mcp4531_cfg[i2c_match_id(mcp4531_id, client)->driver_data];
383374
384
- indio_dev->dev.parent = dev;
385375 indio_dev->info = &mcp4531_info;
386376 indio_dev->channels = mcp4531_channels;
387377 indio_dev->num_channels = data->cfg->wipers;
....@@ -393,7 +383,7 @@
393383 static struct i2c_driver mcp4531_driver = {
394384 .driver = {
395385 .name = "mcp4531",
396
- .of_match_table = of_match_ptr(mcp4531_of_match),
386
+ .of_match_table = mcp4531_of_match,
397387 },
398388 .probe_new = mcp4531_probe,
399389 .id_table = mcp4531_id,
....@@ -403,4 +393,4 @@
403393
404394 MODULE_AUTHOR("Peter Rosin <peda@axentia.se>");
405395 MODULE_DESCRIPTION("MCP4531 digital potentiometer");
406
-MODULE_LICENSE("GPL");
396
+MODULE_LICENSE("GPL v2");