Devicetree
 help / color / mirror / Atom feed
From: Jonathan Cameron <jic23@kernel.org>
To: sashiko-reviews@lists.linux.dev
Cc: Kurt Borja <kuurtb@gmail.com>,
	conor+dt@kernel.org, robh@kernel.org,
	 devicetree@vger.kernel.org
Subject: Re: [PATCH v4 03/10] iio: adc: add the ti-ads1262 driver
Date: Sun, 30 Aug 2026 03:02:55 +0100	[thread overview]
Message-ID: <178805537532.2788519.12150005140246669583.b4-reply@b4> (raw)
In-Reply-To: <20260828065211.C05B11F00A3F@smtp.kernel.org>

> commit 6093db1ff45e9e897720bc6b278550ffbef67e85
> Author: Kurt Borja <kuurtb@gmail.com>
> 
> iio: adc: add the ti-ads1262 driver
> 
> Add the ti-ads1262 driver with initial support for the primary ADC (ADC1).
> Various features such as accurate timeout delays, per-channel reference
> sources, scale, offset, and diagnostics are intentionally left out for
> future support.

One particularly interesting point from sashiko about regmap debugfs.

> 
> > diff --git a/drivers/iio/adc/ti-ads1262.c b/drivers/iio/adc/ti-ads1262.c
> > new file mode 100644
> > --- /dev/null
> > +++ b/drivers/iio/adc/ti-ads1262.c
> 

> > +static int ads1262_channel_read(struct iio_dev *indio_dev,
> > +				const struct iio_chan_spec *spec, __be32 *val)
> > +{
> > +	struct ads1262 *st = iio_priv(indio_dev);
> > +	int ret;
> > +
> > +	IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
> > +	if (IIO_DEV_ACQUIRE_FAILED(claim))
> > +		return -EBUSY;
> > +
> > +	ret = ads1262_set_runmode(st, ADS1262_RUNMODE_PULSE);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = ads1262_channel_enable(st, spec);
> > +	if (ret)
> > +		return ret;
> > +
> > +	reinit_completion(&st->drdy);
> > +
> > +	ret = ads1262_dev_start_one(st);
> > +	if (ret)
> > +		return ret;
> > +
> > +	ret = ads1262_wait_for_conversion(st);
> > +	if (ret)
> > +		return ret;
> 
> [Severity: Medium]
> Does this error path leave the hardware running if the wait is interrupted?
> 
> If ads1262_wait_for_conversion() returns an error (like -ERESTARTSYS from
> a signal), the driver exits immediately without stopping the hardware. If a
> subsequent read calls reinit_completion(&st->drdy), but the abandoned
> hardware conversion finishes and asserts the DRDY interrupt right after,
> could the new read prematurely fetch stale data from the old conversion?
> 
> Should this path ensure the hardware is stopped and synchronized with the
> interrupt handler on timeout or interrupt?

For me this is obscure enough I'm not sure we care about stale data.

> 
> [ ... ]
> 
> > +static int ads1262_dev_configure(struct ads1262 *st)
> > +{
> > +	struct device *dev = &st->spi->dev;
> > +	int id, ret;
> > +
> > +	ret = ads1262_dev_reset(st);
> > +	if (ret)
> > +		return dev_err_probe(dev, ret, "failed to reset device\n");
> > +
> > +	guard(mutex)(&st->xfer_lock);
> > +
> > +	ret = regmap_read(st->regmap, ADS1262_ID_REG, &id);
> 
> [Severity: Low]
> Is the type of id correct here?
> 
> The regmap_read() API expects an unsigned int * for its third argument, but
> id is declared as an int. Could this trigger a -Wpointer-sign compiler
> warning?

This one is minor but good to tidy up.

> 
> [ ... ]
> 
> > +static const struct regmap_config ads1262_regmap_config = {
> > +	.reg_bits = 8,
> > +	.val_bits = 8,
> > +	.writeable_reg = ads1262_writeable_reg,
> > +	.readable_reg = ads1262_readable_reg,
> > +	.volatile_reg = ads1262_volatile_reg,
> > +	.reg_defaults = ads1262_reg_defaults,
> > +	.num_reg_defaults = ARRAY_SIZE(ads1262_reg_defaults),
> > +	.max_register = ADS1262_ADC2FSC1_REG,
> > +	.can_sleep = true,
> > +	.cache_type = REGCACHE_MAPLE,
> > +};
> 
> [ ... ]
> 
> > +static int ads1262_regmap_read(void *context, const void *reg_buf,
> > +			       size_t reg_size, void *val_buf, size_t val_size)
> > +{
> > +	struct ads1262 *st = context;
> > +	u8 tx[2];
> > +
> > +	lockdep_assert_held(&st->xfer_lock);
> 
> [Severity: Medium]
> Will this lockdep assertion fail if the register is read via debugfs?
> 
> Because ads1262_regmap_config does not set disable_locking = true and does
> not provide custom lock/unlock callbacks, regmap uses its own internal
> mutex. When regmap's debugfs interface is read, the regmap core acquires
> its internal mutex and calls the driver's ads1262_regmap_read() callback
> without holding st->xfer_lock.
> 
> Could this bypass the xfer_lock, triggering the lockdep splat and allowing
> debugfs SPI operations to interleave with driver-initiated SPI transactions?

This is a corner I'd not thought about in adding lockdep markings to these
functions.  Up to you how you want to fix it.



  reply	other threads:[~2026-08-30  2:03 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-28  6:38 [PATCH v4 00/10] iio: adc: Add TI ADS126X ADC family support Kurt Borja
2026-08-28  6:38 ` [PATCH v4 01/10] dt-bindings: adc: add excitation-current-chopping property Kurt Borja
2026-08-28 16:33   ` Conor Dooley
2026-08-28  6:38 ` [PATCH v4 02/10] dt-bindings: iio: adc: support the TI ADS126x ADC family Kurt Borja
2026-08-28  6:45   ` sashiko-bot
2026-08-28 16:39   ` Conor Dooley
2026-08-30  1:57     ` Jonathan Cameron
2026-08-30  1:53   ` Jonathan Cameron
2026-08-28  6:38 ` [PATCH v4 03/10] iio: adc: add the ti-ads1262 driver Kurt Borja
2026-08-28  6:52   ` sashiko-bot
2026-08-30  2:02     ` Jonathan Cameron [this message]
2026-08-28  8:09   ` Andy Shevchenko
2026-08-28  6:38 ` [PATCH v4 04/10] iio: adc: ti-ads1262: support per-channel sampling frequency Kurt Borja
2026-08-28  7:03   ` sashiko-bot
2026-08-30  1:36   ` Jonathan Cameron
2026-08-30  2:22   ` Jonathan Cameron
2026-08-28  6:38 ` [PATCH v4 05/10] iio: adc: ti-ads1262: support per-channel reference and gain Kurt Borja
2026-08-28  6:38 ` [PATCH v4 06/10] iio: adc: ti-ads1262: support input chopping Kurt Borja
2026-08-28  6:38 ` [PATCH v4 07/10] iio: adc: ti-ads1262: support excitation currents Kurt Borja
2026-08-28  6:57   ` sashiko-bot
2026-08-28  6:38 ` [PATCH v4 08/10] iio: adc: ti-ads1262: support triggered buffer sampling Kurt Borja
2026-08-28  6:57   ` sashiko-bot
2026-08-28  6:38 ` [PATCH v4 09/10] iio: adc: ti-ads1262: support REFOUT and VBIAS regulators Kurt Borja
2026-08-28  6:53   ` sashiko-bot
2026-08-28  6:38 ` [PATCH v4 10/10] iio: adc: ti-ads1262: support common mode supplies Kurt Borja
2026-08-28  7:03   ` sashiko-bot

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=178805537532.2788519.12150005140246669583.b4-reply@b4 \
    --to=jic23@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kuurtb@gmail.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