Re: [PATCH 1/2] iio: adc: ad7291: convert to device tree

From: Lars-Peter Clausen
Date: Tue Mar 17 2020 - 10:16:24 EST


On 3/17/20 2:56 PM, Michael Auchter wrote:
There are no in-tree users of the platform data for this driver, so
remove it and convert the driver to use device tree instead.

Signed-off-by: Michael Auchter <michael.auchter@xxxxxx>

Hi,

Thanks for the patch, looks good for the most part. One comment inline.


diff --git a/drivers/iio/adc/ad7291.c b/drivers/iio/adc/ad7291.c
index b2b137fed246..536e31862309 100644
--- a/drivers/iio/adc/ad7291.c
+++ b/drivers/iio/adc/ad7291.c
@@ -495,8 +482,19 @@ static int ad7291_probe(struct i2c_client *client,
AD7291_T_SENSE_MASK | /* Tsense always enabled */
AD7291_ALERT_POLARITY; /* set irq polarity low level */
- if (pdata && pdata->use_external_ref)
+ chip->reg = devm_regulator_get_optional(&client->dev, "vref");
+ if (IS_ERR(chip->reg)) {
+ if (PTR_ERR(chip->reg) == -EPROBE_DEFER)
+ return -EPROBE_DEFER;

We should only continue if the error is ENODEV, which means that no regulator was specified. Any other error means it was specified but there was an issue requesting it. See for example ad7266.c

+
+ chip->reg = NULL;
+ } else {
+ ret = regulator_enable(chip->reg);
+ if (ret)
+ return ret;
+
chip->command |= AD7291_EXT_REF;
+ }