From: Angelo Dureghello <adureghello@baylibre.com>
Add optional refin voltage enabling. The property "refin-supply" is
already available and optional in the current fdt dt_schema.
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
---
drivers/iio/adc/ad7606.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
index 3bbe9c05b5edbc11e8016c995c6ab64104836e7b..21e63260965c32988d0ab3b8bb1201aa2396f1ba 100644
--- a/drivers/iio/adc/ad7606.c
+++ b/drivers/iio/adc/ad7606.c
@@ -1335,6 +1335,10 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
return dev_err_probe(dev, ret,
"Failed to enable Vdrive supply\n");
+ ret = devm_regulator_get_enable_optional(dev, "refin");
+ if (ret < 0 && ret != -ENODEV)
+ return dev_err_probe(dev, ret, "failed to get refin voltage\n");
+
st->chip_info = chip_info;
if (st->chip_info->oversampling_num) {
--
2.49.0
On 5/29/25 4:13 AM, Angelo Dureghello wrote:
> From: Angelo Dureghello <adureghello@baylibre.com>
>
> Add optional refin voltage enabling. The property "refin-supply" is
> already available and optional in the current fdt dt_schema.
>
> Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> ---
> drivers/iio/adc/ad7606.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> index 3bbe9c05b5edbc11e8016c995c6ab64104836e7b..21e63260965c32988d0ab3b8bb1201aa2396f1ba 100644
> --- a/drivers/iio/adc/ad7606.c
> +++ b/drivers/iio/adc/ad7606.c
> @@ -1335,6 +1335,10 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
> return dev_err_probe(dev, ret,
> "Failed to enable Vdrive supply\n");
>
> + ret = devm_regulator_get_enable_optional(dev, "refin");
> + if (ret < 0 && ret != -ENODEV)
< 0 is probably not needed.
> + return dev_err_probe(dev, ret, "failed to get refin voltage\n");
We aren't reading the voltage, so the message doesn't make sense.
> +
> st->chip_info = chip_info;
>
> if (st->chip_info->oversampling_num) {
>
On 29.05.2025 12:52, David Lechner wrote:
> On 5/29/25 4:13 AM, Angelo Dureghello wrote:
> > From: Angelo Dureghello <adureghello@baylibre.com>
> >
> > Add optional refin voltage enabling. The property "refin-supply" is
> > already available and optional in the current fdt dt_schema.
> >
> > Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
> > ---
> > drivers/iio/adc/ad7606.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
> > index 3bbe9c05b5edbc11e8016c995c6ab64104836e7b..21e63260965c32988d0ab3b8bb1201aa2396f1ba 100644
> > --- a/drivers/iio/adc/ad7606.c
> > +++ b/drivers/iio/adc/ad7606.c
> > @@ -1335,6 +1335,10 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
> > return dev_err_probe(dev, ret,
> > "Failed to enable Vdrive supply\n");
> >
> > + ret = devm_regulator_get_enable_optional(dev, "refin");
> > + if (ret < 0 && ret != -ENODEV)
>
> < 0 is probably not needed.
>
The above code looks correct to me. What is the issue ?
> > + return dev_err_probe(dev, ret, "failed to get refin voltage\n");
>
> We aren't reading the voltage, so the message doesn't make sense.
>
Is it better a
"failed to get refin-supply\n" or
"failed to enable refin voltage\n"
?
> > +
> > st->chip_info = chip_info;
> >
> > if (st->chip_info->oversampling_num) {
> >
>
Regards,
angelo
On 5/30/25 2:39 AM, Angelo Dureghello wrote:
> On 29.05.2025 12:52, David Lechner wrote:
>> On 5/29/25 4:13 AM, Angelo Dureghello wrote:
>>> From: Angelo Dureghello <adureghello@baylibre.com>
>>>
>>> Add optional refin voltage enabling. The property "refin-supply" is
>>> already available and optional in the current fdt dt_schema.
>>>
>>> Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
>>> ---
>>> drivers/iio/adc/ad7606.c | 4 ++++
>>> 1 file changed, 4 insertions(+)
>>>
>>> diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c
>>> index 3bbe9c05b5edbc11e8016c995c6ab64104836e7b..21e63260965c32988d0ab3b8bb1201aa2396f1ba 100644
>>> --- a/drivers/iio/adc/ad7606.c
>>> +++ b/drivers/iio/adc/ad7606.c
>>> @@ -1335,6 +1335,10 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address,
>>> return dev_err_probe(dev, ret,
>>> "Failed to enable Vdrive supply\n");
>>>
>>> + ret = devm_regulator_get_enable_optional(dev, "refin");
>>> + if (ret < 0 && ret != -ENODEV)
>>
>> < 0 is probably not needed.
>>
> The above code looks correct to me. What is the issue ?
Like Nuno said, it can't be > 0, so if (ret && ret != -ENODEV)
>
>>> + return dev_err_probe(dev, ret, "failed to get refin voltage\n");
>>
>> We aren't reading the voltage, so the message doesn't make sense.
>>
> Is it better a
> "failed to get refin-supply\n" or
> "failed to enable refin voltage\n"
I would make the message the same as Vdrive.
"Failed to enable REFIN supply\n");
>
> ?
>
>>> +
>>> st->chip_info = chip_info;
>>>
>>> if (st->chip_info->oversampling_num) {
>>>
>>
> Regards,
> angelo
On Fri, 2025-05-30 at 09:39 +0200, Angelo Dureghello wrote: > On 29.05.2025 12:52, David Lechner wrote: > > On 5/29/25 4:13 AM, Angelo Dureghello wrote: > > > From: Angelo Dureghello <adureghello@baylibre.com> > > > > > > Add optional refin voltage enabling. The property "refin-supply" is > > > already available and optional in the current fdt dt_schema. > > > > > > Signed-off-by: Angelo Dureghello <adureghello@baylibre.com> > > > --- > > > drivers/iio/adc/ad7606.c | 4 ++++ > > > 1 file changed, 4 insertions(+) > > > > > > diff --git a/drivers/iio/adc/ad7606.c b/drivers/iio/adc/ad7606.c > > > index > > > 3bbe9c05b5edbc11e8016c995c6ab64104836e7b..21e63260965c32988d0ab3b8bb1201aa > > > 2396f1ba 100644 > > > --- a/drivers/iio/adc/ad7606.c > > > +++ b/drivers/iio/adc/ad7606.c > > > @@ -1335,6 +1335,10 @@ int ad7606_probe(struct device *dev, int irq, void > > > __iomem *base_address, > > > return dev_err_probe(dev, ret, > > > "Failed to enable Vdrive supply\n"); > > > > > > + ret = devm_regulator_get_enable_optional(dev, "refin"); > > > + if (ret < 0 && ret != -ENODEV) > > > > < 0 is probably not needed. > > > The above code looks correct to me. What is the issue ? > Not that there's an issue with the code. I think David means that ret > 0 has no meaning (function on return values <= 0) which means that if (ret) is enough. - Nuno Sá
© 2016 - 2025 Red Hat, Inc.