From: David Lechner <dlechner@baylibre.com>
To: "Angelo Dureghello" <adureghello@baylibre.com>,
"Nuno Sá" <noname.nuno@gmail.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 v3 5/5] iio: adc: ad7606: add gain calibration support
Date: Thu, 8 May 2025 08:50:56 -0500 [thread overview]
Message-ID: <7f5f75c1-7750-4966-9362-2a46c5e5ba3e@baylibre.com> (raw)
In-Reply-To: <qaiqdak4pieewavl2ff4mpr2ywhw2bvnoob55buiinkisacar5@q6jhlb5klcf6>
On 5/8/25 4:16 AM, Angelo Dureghello wrote:
> Hi all,
> On 07.05.2025 07:14, Nuno Sá wrote:
>> On Tue, 2025-05-06 at 23:03 +0200, 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) {
>>> + u32 reg, r_gain;
>>> +
>
> working on further features, i noticed this function is called
> for each channel, that is not correct, so need to fix this,
> will send a v4.
Why is this not correct? Each input could have an amplifier with different
series resistor value so this seems correct to me.
>
> Regards,
> angelo
>
>>> + 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, "wrong ch number (ignoring): %d\n", reg);
>>> + continue;
>>> + }
>>> +
>>
>> Sorry Angelo, just realized this now. Any reason for not treating the above as a real
>> invalid argument? It's minor and not a big deal but odd enough...
>>
>> - Nuno Sá
>>
>>> + ret = fwnode_property_read_u32(child, "adi,rfilter-ohms",
>>> + &r_gain);
>>> + if (ret == -EINVAL)
>>> + /* Keep the default register value. */
>>> + continue;
>>> + if (ret)
>>> + return ret;
>>> +
>>> + if (r_gain > AD7606_CALIB_GAIN_MAX)
>>> + return dev_err_probe(st->dev, -EINVAL,
>>> + "wrong gain calibration value.");
>>> +
>>> + /* Chan reg is 1-based index. */
>>> + ret = st->bops->reg_write(st, AD7606_CALIB_GAIN(reg - 1),
>>> + DIV_ROUND_CLOSEST(r_gain, AD7606_CALIB_GAIN_STEP));
>>> + if (ret)
>>> + return ret;
>>> + }
>>> +
>>> + return 0;
>>> +}
>>> +
next prev parent reply other threads:[~2025-05-08 13:50 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-06 21:03 [PATCH v3 0/5] iio: adc: add ad7606 calibration support Angelo Dureghello
2025-05-06 21:03 ` [PATCH v3 1/5] Documentation: ABI: IIO: add calibconv_delay documentation Angelo Dureghello
2025-05-06 21:03 ` [PATCH v3 2/5] iio: core: add ADC delay calibration definition Angelo Dureghello
2025-05-06 21:03 ` [PATCH v3 3/5] iio: adc: ad7606: add offset and phase calibration support Angelo Dureghello
2025-05-06 21:03 ` [PATCH v3 4/5] dt-bindings: iio: adc: adi,ad7606: add gain " Angelo Dureghello
2025-05-06 21:03 ` [PATCH v3 5/5] iio: adc: ad7606: " Angelo Dureghello
2025-05-07 6:14 ` Nuno Sá
2025-05-07 8:52 ` Angelo Dureghello
2025-05-08 9:16 ` Angelo Dureghello
2025-05-08 13:50 ` David Lechner [this message]
2025-05-08 16:27 ` David Lechner
2025-05-08 16:35 ` David Lechner
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=7f5f75c1-7750-4966-9362-2a46c5e5ba3e@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=noname.nuno@gmail.com \
--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