hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/drivers/iio/adc/ad7291.c
....@@ -1,9 +1,8 @@
1
+// SPDX-License-Identifier: GPL-2.0-or-later
12 /*
23 * AD7291 8-Channel, I2C, 12-Bit SAR ADC with Temperature Sensor
34 *
45 * Copyright 2010-2011 Analog Devices Inc.
5
- *
6
- * Licensed under the GPL-2 or later.
76 */
87
98 #include <linux/device.h>
....@@ -20,8 +19,6 @@
2019 #include <linux/iio/iio.h>
2120 #include <linux/iio/sysfs.h>
2221 #include <linux/iio/events.h>
23
-
24
-#include <linux/platform_data/ad7291.h>
2522
2623 /*
2724 * Simplified handling
....@@ -466,7 +463,6 @@
466463 static int ad7291_probe(struct i2c_client *client,
467464 const struct i2c_device_id *id)
468465 {
469
- struct ad7291_platform_data *pdata = client->dev.platform_data;
470466 struct ad7291_chip_info *chip;
471467 struct iio_dev *indio_dev;
472468 int ret;
....@@ -475,16 +471,6 @@
475471 if (!indio_dev)
476472 return -ENOMEM;
477473 chip = iio_priv(indio_dev);
478
-
479
- if (pdata && pdata->use_external_ref) {
480
- chip->reg = devm_regulator_get(&client->dev, "vref");
481
- if (IS_ERR(chip->reg))
482
- return PTR_ERR(chip->reg);
483
-
484
- ret = regulator_enable(chip->reg);
485
- if (ret)
486
- return ret;
487
- }
488474
489475 mutex_init(&chip->state_lock);
490476 /* this is only used for device removal purposes */
....@@ -496,15 +482,26 @@
496482 AD7291_T_SENSE_MASK | /* Tsense always enabled */
497483 AD7291_ALERT_POLARITY; /* set irq polarity low level */
498484
499
- if (pdata && pdata->use_external_ref)
485
+ chip->reg = devm_regulator_get_optional(&client->dev, "vref");
486
+ if (IS_ERR(chip->reg)) {
487
+ if (PTR_ERR(chip->reg) != -ENODEV)
488
+ return PTR_ERR(chip->reg);
489
+
490
+ chip->reg = NULL;
491
+ }
492
+
493
+ if (chip->reg) {
494
+ ret = regulator_enable(chip->reg);
495
+ if (ret)
496
+ return ret;
497
+
500498 chip->command |= AD7291_EXT_REF;
499
+ }
501500
502501 indio_dev->name = id->name;
503502 indio_dev->channels = ad7291_channels;
504503 indio_dev->num_channels = ARRAY_SIZE(ad7291_channels);
505504
506
- indio_dev->dev.parent = &client->dev;
507
- indio_dev->dev.of_node = client->dev.of_node;
508505 indio_dev->info = &ad7291_info;
509506 indio_dev->modes = INDIO_DIRECT_MODE;
510507
....@@ -570,9 +567,16 @@
570567
571568 MODULE_DEVICE_TABLE(i2c, ad7291_id);
572569
570
+static const struct of_device_id ad7291_of_match[] = {
571
+ { .compatible = "adi,ad7291" },
572
+ {}
573
+};
574
+MODULE_DEVICE_TABLE(of, ad7291_of_match);
575
+
573576 static struct i2c_driver ad7291_driver = {
574577 .driver = {
575578 .name = KBUILD_MODNAME,
579
+ .of_match_table = ad7291_of_match,
576580 },
577581 .probe = ad7291_probe,
578582 .remove = ad7291_remove,