Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Marcelo Schmitt" <marcelo.schmitt@analog.com>,
	devicetree@vger.kernel.org
Cc: robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v2 5/5] iio: adc: Add support for ADA4355 and similar ADCs
Date: Fri, 27 Nov 2026 22:06:52 +0000	[thread overview]
Message-ID: <sashiko-outbox-238318@kernel.org> (raw)
In-Reply-To: <e82c0e4ce3968c6e26e05223510e8b51972a6e44.1795816065.git.marcelo.schmitt@analog.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [Medium] iio: adc: ada4355: pass ret instead of PTR_ERR(st->back) in
  ada4355_probe()
- [Medium] iio: adc: ada4355: missing cleanup on frame error in
  ada4355_calibrate()
- [Medium] iio: adc: ada4355: reject non-positive sampling freq in
  ada4355_write_raw()
- [Medium] iio: adc: ada4355: missing vea and ved supply enable in
  ada4355_probe()
--

commit 16b7c5a177ca16d48ca83a8d082c7d1e3ecf562a
Author: Marcelo Schmitt <marcelo.schmitt@analog.com>

iio: adc: Add support for ADA4355 and similar ADCs

This commit adds an IIO ADC driver for the Analog Devices ADA4355 and
ADA4356 14-bit, 125 MSPS analog-to-digital converters with IIO backend
support.

> diff --git a/drivers/iio/adc/ada4355.c b/drivers/iio/adc/ada4355.c
> new file mode 100644
> index 0000000000000..5a3f480362538
> --- /dev/null
> +++ b/drivers/iio/adc/ada4355.c
> @@ -0,0 +1,822 @@

[ ... ]

> +static int ada4355_calibrate(struct ada4355_state *st)
> +{
> +	int ret, ret2;
> +
> +	/* all points invalid */
> +	bitmap_fill(st->calib_map, st->calib_map_size);
> +
> +	ret = ada4355_calibrate_prepare(st);
> +	if (ret)
> +		return ret;
> +
> +	/*
> +	 * The frame signal has to be aligned first: the pattern match block
> +	 * only reports meaningful per-lane errors once the word boundary is
> +	 * known.
> +	 */
> +	ret = ada4355_calibrate_lane(st, IIO_BACKEND_CALIB_SOURCE_FRAME,
> +				     ADA4355_FRAME_LANE,
> +				     ADA4355_MAX_DATA_LANES * ADA4355_MAX_TEST_POINTS);
> +	if (ret)
> +		return ret;

[Severity: Medium]
Should this error path call ada4355_calibrate_stop(st) like the data-lane
loop below does?  If frame-lane calibration fails during a runtime clock
update (ada4355_write_raw() -> ada4355_update_clock()), returning directly
leaves backend channel 0 enabled and the ADC stuck in
ADA4355_TEST_MODE_USER outputting the 0xFFFC calibration pattern.

[ ... ]

> +static int ada4355_write_raw(struct iio_dev *indio_dev,
> +			     struct iio_chan_spec const *chan,
> +			     int val, int val2, long mask)
> +{
> +	struct ada4355_state *st = iio_priv(indio_dev);
> +	long r_clk;
> +
> +	IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
> +	if (IIO_DEV_ACQUIRE_FAILED(claim))
> +		return -EBUSY;
> +
> +	switch (mask) {
> +	case IIO_CHAN_INFO_SAMP_FREQ:
> +		r_clk = clk_round_rate(st->clk, val);
> +		if (r_clk < 1 || r_clk > ADA4355_MAX_SAMP_RATE_SPS)
> +			return -ERANGE;
> +
> +		return ada4355_update_clock(st, r_clk);

[Severity: Medium]
Should val <= 0 be rejected before calling clk_round_rate()?
clk_round_rate() takes an unsigned long, so a negative val wraps to a large
positive rate that the clock provider can clamp into
[1, ADA4355_MAX_SAMP_RATE_SPS] (and 0 can round up to the minimum supported
rate), reconfiguring the ADC clock instead of returning an error.

[ ... ]

> +static int ada4355_probe(struct spi_device *spi)
> +{

[ ... ]

> +	ret = devm_regulator_get_enable(dev, "vcc");
> +	if (ret < 0)
> +		return dev_err_probe(dev, PTR_ERR(st->back),
> +				     "failed to get vcc supply\n");

[Severity: Medium]
Does this pass PTR_ERR(st->back) instead of ret to dev_err_probe()?
st->back is still NULL here, so ada4355_probe() returns 0 on regulator
failure, skipping deferred probe and leaving the device bound without
completing setup or registering the IIO device.

[Severity: Medium]
Should ada4355_probe() also enable the vea and ved supplies?  The
Documentation/devicetree/bindings/iio/adc/adi,ada4355.yaml binding defines
vea-supply and ved-supply for the 1.8V analog and digital ADC rails, so
boards driving them from external regulators will leave those rails
unpowered.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1795816065.git.marcelo.schmitt@analog.com?part=5

      reply	other threads:[~2026-11-27 22:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 21:51 [PATCH v2 0/5] Add support for ADA4355 Marcelo Schmitt
2026-11-27 21:51 ` [PATCH v2 1/5] iio: backend: Add calibration source interface Marcelo Schmitt
2026-11-27 21:52 ` [PATCH v2 2/5] dt-bindings: iio: adc: Add AXI ADA4355 IP CORE Marcelo Schmitt
2026-11-27 21:52 ` [PATCH v2 3/5] iio: adc: adi-axi-adc: Support AXI ADA4355 IP core Marcelo Schmitt
2026-11-27 21:52 ` [PATCH v2 4/5] dt-bindings: iio: adc: Add ADA4355 Marcelo Schmitt
2026-11-27 22:07   ` sashiko-bot
2026-11-27 21:53 ` [PATCH v2 5/5] iio: adc: Add support for ADA4355 and similar ADCs Marcelo Schmitt
2026-11-27 22:06   ` sashiko-bot [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=sashiko-outbox-238318@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=marcelo.schmitt@analog.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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