.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-or-later |
---|
1 | 2 | /* |
---|
2 | 3 | * AD7291 8-Channel, I2C, 12-Bit SAR ADC with Temperature Sensor |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright 2010-2011 Analog Devices Inc. |
---|
5 | | - * |
---|
6 | | - * Licensed under the GPL-2 or later. |
---|
7 | 6 | */ |
---|
8 | 7 | |
---|
9 | 8 | #include <linux/device.h> |
---|
.. | .. |
---|
20 | 19 | #include <linux/iio/iio.h> |
---|
21 | 20 | #include <linux/iio/sysfs.h> |
---|
22 | 21 | #include <linux/iio/events.h> |
---|
23 | | - |
---|
24 | | -#include <linux/platform_data/ad7291.h> |
---|
25 | 22 | |
---|
26 | 23 | /* |
---|
27 | 24 | * Simplified handling |
---|
.. | .. |
---|
466 | 463 | static int ad7291_probe(struct i2c_client *client, |
---|
467 | 464 | const struct i2c_device_id *id) |
---|
468 | 465 | { |
---|
469 | | - struct ad7291_platform_data *pdata = client->dev.platform_data; |
---|
470 | 466 | struct ad7291_chip_info *chip; |
---|
471 | 467 | struct iio_dev *indio_dev; |
---|
472 | 468 | int ret; |
---|
.. | .. |
---|
475 | 471 | if (!indio_dev) |
---|
476 | 472 | return -ENOMEM; |
---|
477 | 473 | 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 | | - } |
---|
488 | 474 | |
---|
489 | 475 | mutex_init(&chip->state_lock); |
---|
490 | 476 | /* this is only used for device removal purposes */ |
---|
.. | .. |
---|
496 | 482 | AD7291_T_SENSE_MASK | /* Tsense always enabled */ |
---|
497 | 483 | AD7291_ALERT_POLARITY; /* set irq polarity low level */ |
---|
498 | 484 | |
---|
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 | + |
---|
500 | 498 | chip->command |= AD7291_EXT_REF; |
---|
| 499 | + } |
---|
501 | 500 | |
---|
502 | 501 | indio_dev->name = id->name; |
---|
503 | 502 | indio_dev->channels = ad7291_channels; |
---|
504 | 503 | indio_dev->num_channels = ARRAY_SIZE(ad7291_channels); |
---|
505 | 504 | |
---|
506 | | - indio_dev->dev.parent = &client->dev; |
---|
507 | | - indio_dev->dev.of_node = client->dev.of_node; |
---|
508 | 505 | indio_dev->info = &ad7291_info; |
---|
509 | 506 | indio_dev->modes = INDIO_DIRECT_MODE; |
---|
510 | 507 | |
---|
.. | .. |
---|
570 | 567 | |
---|
571 | 568 | MODULE_DEVICE_TABLE(i2c, ad7291_id); |
---|
572 | 569 | |
---|
| 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 | + |
---|
573 | 576 | static struct i2c_driver ad7291_driver = { |
---|
574 | 577 | .driver = { |
---|
575 | 578 | .name = KBUILD_MODNAME, |
---|
| 579 | + .of_match_table = ad7291_of_match, |
---|
576 | 580 | }, |
---|
577 | 581 | .probe = ad7291_probe, |
---|
578 | 582 | .remove = ad7291_remove, |
---|