Re: [PATCH v6 06/16] iio: adc: ad4134: Protect conventional device access from debug accesses

From: Jonathan Cameron

Date: Fri Oct 23 2026 - 21:46:34 EST


On Fri, 23 Oct 2026 19:34:50 -0300
Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx> wrote:

> AD4134 sample read operations may more than one transfer to complete and

may require more than one?

> are expected to run atomically to avoid triggering any DCLK count error.
> Though, register access made from debugfs interface may scramble data if
> they are run amidst sample read operations and read/write/modify cycles.
>
> Require debug access to acquire device synchronization locks before
> running any transfer requested from debugfs interface.
>
> Signed-off-by: Marcelo Schmitt <marcelo.schmitt@xxxxxxxxxx>
> ---
> Change log v5 -> v6:
> - Better explanation for requiring debugfs synchronization.
>
> drivers/iio/adc/ad4134.c | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> diff --git a/drivers/iio/adc/ad4134.c b/drivers/iio/adc/ad4134.c
> index 1cfa8066f13f..71f626bbe9be 100644
> --- a/drivers/iio/adc/ad4134.c
> +++ b/drivers/iio/adc/ad4134.c
> @@ -302,6 +302,12 @@ static int ad4134_debugfs_reg_access(struct iio_dev *indio_dev,
> {
> struct ad4134_state *st = iio_priv(indio_dev);
>
> + IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
> + if (IIO_DEV_ACQUIRE_FAILED(claim))
> + return -EBUSY;
> +
> + guard(mutex)(&st->sync_lock);
> +
> if (readval)
> return regmap_read(st->regmap, reg, readval);
>