From: Jonathan Cameron <jic23@kernel.org>
To: Nuno Sa <nuno.sa@analog.com>
Cc: <linux-iio@vger.kernel.org>, <devicetree@vger.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>
Subject: Re: [PATCH 1/5] iio: adc: ad9467: support multiple channels calibration
Date: Sat, 6 Jul 2024 12:16:54 +0100 [thread overview]
Message-ID: <20240706121654.12d3bb38@jic23-huawei> (raw)
In-Reply-To: <20240704-dev-iio-ad9467-new-devs-v1-1-f1adfee921f7@analog.com>
On Thu, 4 Jul 2024 11:25:21 +0200
Nuno Sa <nuno.sa@analog.com> wrote:
> The calibration process mixes the support for calibrating multiple
> channels with only having one channel. Some paths do have 'num_channels'
> into account while others don't.
>
> As of now, the driver only supports devices with one channel so the
> above is not really a problem. That said, we'll add support for devices
> with more than one channel, hence let's properly make the calibration
> process to work with it.
>
> Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Hi Nuno,
Not suggesting you change it here, but one place where I think
the existing code readability could be improved.
> static int ad9467_calibrate(struct ad9467_state *st)
> {
> - unsigned int point, val, inv_val, cnt, inv_cnt = 0;
> + unsigned int point, val, inv_val, cnt, inv_cnt = 0, c;
Comment on existing code. I'm not keen on mix of assignment and non
assignment in a single line of local variable declarations.
It can get hard to spot what is assigned!
> /*
> * Half of the bitmap is for the inverted signal. The number of test
> * points is the same though...
> @@ -526,11 +546,26 @@ static int ad9467_calibrate(struct ad9467_state *st)
> if (ret)
> return ret;
>
> - ret = iio_backend_chan_status(st->back, 0, &stat);
> - if (ret)
> - return ret;
> + for (c = 0; c < st->info->num_channels; c++) {
> + ret = iio_backend_chan_status(st->back, c, &stat);
> + if (ret)
> + return ret;
>
> - __assign_bit(point + invert * test_points, st->calib_map, stat);
> + /*
> + * A point is considered valid if all channels report no
> + * error. If one reports an error, then we consider the
> + * point as invalid and we can break the loop right away.
> + */
> + if (stat) {
> + dev_dbg(dev, "Invalid point(%u, inv:%u) for CH:%u\n",
> + point, invert, c);
> + break;
> + }
> +
> + if (c == st->info->num_channels - 1)
> + __clear_bit(point + invert * test_points,
> + st->calib_map);
> + }
> }
>
> if (!invert) {
>
next prev parent reply other threads:[~2024-07-06 11:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-04 9:25 [PATCH 0/5] iio: adc: ad9467: support new devices Nuno Sa
2024-07-04 9:25 ` [PATCH 1/5] iio: adc: ad9467: support multiple channels calibration Nuno Sa
2024-07-06 11:16 ` Jonathan Cameron [this message]
2024-07-04 9:25 ` [PATCH 2/5] iio: adc: ad9467: add new chip_info variables Nuno Sa
2024-07-04 9:25 ` [PATCH 3/5] iio: adc: ad9467: don't allow reading vref if not available Nuno Sa
2024-07-06 11:20 ` Jonathan Cameron
2024-07-04 9:25 ` [PATCH 4/5] dt-bindings: adc: ad9467: support new parts Nuno Sa
2024-07-04 14:23 ` Krzysztof Kozlowski
2024-07-04 9:25 ` [PATCH 5/5] iio: " Nuno Sa
2024-07-06 11:30 ` [PATCH 0/5] iio: adc: ad9467: support new devices Jonathan Cameron
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=20240706121654.12d3bb38@jic23-huawei \
--to=jic23@kernel.org \
--cc=Michael.Hennerich@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=lars@metafoo.de \
--cc=linux-iio@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