From: David Lechner <dlechner@baylibre.com>
To: Angelo Dureghello <adureghello@baylibre.com>
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Michael Hennerich" <Michael.Hennerich@analog.com>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
devicetree@vger.kernel.org
Subject: Re: [PATCH 5/5] iio: adc: ad7606: add gain calibration support
Date: Thu, 1 May 2025 09:26:11 -0500 [thread overview]
Message-ID: <60986dd1-e03c-47f7-980c-879a5ecf7c44@baylibre.com> (raw)
In-Reply-To: <y6hss7bo25hiwzzplbbhmdodpmqbgpkarqvemn3tn3fig26tb2@753sxtygndaz>
On 5/1/25 8:35 AM, Angelo Dureghello wrote:
> On 29.04.2025 17:46, David Lechner wrote:
>> On 4/29/25 8:06 AM, Angelo Dureghello wrote:
>>> From: Angelo Dureghello <adureghello@baylibre.com>
>>>
>>
>> ...
>>
>>> +static int ad7606_chan_calib_gain_setup(struct iio_dev *indio_dev,
>>> + struct iio_chan_spec *chan)
>>> +{
>>> + struct ad7606_state *st = iio_priv(indio_dev);
>>> + unsigned int num_channels = st->chip_info->num_adc_channels;
>>> + struct device *dev = st->dev;
>>> + int ret;
>>> +
>>> + device_for_each_child_node_scoped(dev, child) {
>>> + int reg, r_gain;
>>> +
>>> + ret = fwnode_property_read_u32(child, "reg", ®);
>>> + if (ret)
>>> + return ret;
>>> +
>>> + /* channel number (here) is from 1 to num_channels */
>>> + if (reg < 1 || reg > num_channels) {
>>> + dev_warn(dev, "invalid ch number (ignoring): %d\n", reg);
>>> + continue;
>>> + }
>>> +
>>> + ret = fwnode_property_read_u32(child, "adi,rfilter-ohms",
>>> + &r_gain);
>>
>> Instead of...
>>
>>> + if (ret)
>>> + return ret;
>>
>> ... we need:
>>
>> if (ret == -EINVAL)
>> r_gain = 0;
>> else if (ret)
>> return ret;
>>
>> Otherwise driver fails to probe if adi,rfilter-ohms is missing.
>>
>
> Correct, i changed this before sending and could not catch it.
> But not totally sure of applying a 0.
> We are here after chip reset. So conceptually, would not apply any default,
> ince it is already set after reset. What about:
>
> if (ret == -EINVAL)
> contnue;
> else if (ret)
> return ret;
Sure. A comment could help here and the continue makes else not needed.
if (ret == -EINVAL)
/* Keep the default register value. */
contnue;
if (ret)
return ret;
>
>>> +
>>> + if (r_gain < AD7606_CALIB_GAIN_MIN ||
>>> + r_gain > AD7606_CALIB_GAIN_MAX)
>>> + return -EINVAL;
>>> +
>>
>> Also, return dev_err_probe() on the returns above would have made debugging
>> easier.
>>
> ack
>
>>> + /* Chan reg is 1-based index. */
>>> + ret = st->bops->reg_write(st, AD7606_CALIB_GAIN(reg - 1),
>>> + r_gain / AD7606_CALIB_GAIN_STEP);
>>> + if (ret)
>>> + return ret;
>>> + }
>>> +
>>> + return 0;
>>> +}
>>> +
prev parent reply other threads:[~2025-05-01 14:26 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 13:06 [PATCH 0/5] iio: adc: add ad7606 calibration support Angelo Dureghello
2025-04-29 13:06 ` [PATCH 1/5] Documentation: ABI: IIO: add calibphase_delay documentation Angelo Dureghello
2025-04-30 5:40 ` Nuno Sá
2025-04-30 14:21 ` David Lechner
2025-04-30 14:45 ` Andy Shevchenko
2025-04-30 14:56 ` David Lechner
2025-04-30 15:04 ` David Lechner
2025-05-01 12:33 ` Angelo Dureghello
2025-05-01 14:44 ` David Lechner
2025-05-04 15:04 ` Jonathan Cameron
2025-04-29 13:06 ` [PATCH 2/5] iio: core: add ADC phase calibration definition Angelo Dureghello
2025-04-29 13:06 ` [PATCH 3/5] iio: adc: ad7606: add offset and phase calibration support Angelo Dureghello
2025-04-30 12:50 ` Andy Shevchenko
2025-05-01 12:37 ` Angelo Dureghello
2025-04-30 15:36 ` Nuno Sá
2025-04-30 16:14 ` David Lechner
2025-04-30 18:33 ` David Lechner
2025-05-02 7:43 ` Nuno Sá
2025-04-29 13:06 ` [PATCH 4/5] dt-bindings: iio: adc: adi,ad7606: add gain " Angelo Dureghello
2025-04-29 14:56 ` Conor Dooley
2025-04-29 15:26 ` David Lechner
2025-04-29 20:45 ` Angelo Dureghello
2025-04-29 13:06 ` [PATCH 5/5] iio: adc: ad7606: " Angelo Dureghello
2025-04-29 22:34 ` Andy Shevchenko
2025-05-01 13:49 ` Angelo Dureghello
2025-04-29 22:46 ` David Lechner
2025-05-01 13:35 ` Angelo Dureghello
2025-05-01 14:26 ` David Lechner [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=60986dd1-e03c-47f7-980c-879a5ecf7c44@baylibre.com \
--to=dlechner@baylibre.com \
--cc=Michael.Hennerich@analog.com \
--cc=adureghello@baylibre.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox