Re: [PATCH v3 4/4] iio: adc: ad9467: check for backend capabilities
From: Nuno Sá
Date: Wed Jan 14 2026 - 08:37:34 EST
On Wed, 2026-01-14 at 10:45 +0000, Tomas Melin wrote:
> Add capability checks for operation with backends that do not support
> full set of features, but are otherwise compatible with the device.
>
> Signed-off-by: Tomas Melin <tomas.melin@xxxxxxxxxxx>
> ---
Another thing is that we also need to care about ad9467_debugfs_init(). No point in
adding that interface if we cannot do (or get) anything with it.
I guess we can still have the device specific test modes (without going to the backend)
but "calibration_table_dump" does not make sense to add if IIO_BACKEND_CAP_CALIBRATION is off.
With a dummy backend, iio_backend_debugfs_add() should already be a no-op.
- Nuno Sá
> drivers/iio/adc/ad9467.c | 11 ++++++++++-
> 1 file changed, 10 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/ad9467.c b/drivers/iio/adc/ad9467.c
> index 9cfe66425d4e91e215cccc40e24a92c5e99e9b87..349779a049ad68b4c9f72abfc40154b4a3f2e095 100644
> --- a/drivers/iio/adc/ad9467.c
> +++ b/drivers/iio/adc/ad9467.c
> @@ -645,6 +645,9 @@ static int ad9467_backend_testmode_on(struct ad9467_state *st,
> };
> int ret;
>
> + if (!iio_backend_has_caps(st->back, IIO_BACKEND_CAP_CALIBRATION))
> + return 0;
> +
> ret = iio_backend_data_format_set(st->back, chan, &data);
> if (ret)
> return ret;
> @@ -665,6 +668,9 @@ static int ad9467_backend_testmode_off(struct ad9467_state *st,
> };
> int ret;
>
> + if (!iio_backend_has_caps(st->back, IIO_BACKEND_CAP_CALIBRATION))
> + return 0;
> +
> ret = iio_backend_chan_disable(st->back, chan);
> if (ret)
> return ret;
> @@ -807,6 +813,9 @@ static int ad9467_calibrate(struct ad9467_state *st)
> bool invert = false, stat;
> int ret;
>
> + if (!iio_backend_has_caps(st->back, IIO_BACKEND_CAP_CALIBRATION))
> + return 0;
> +
> /* all points invalid */
> bitmap_fill(st->calib_map, st->calib_map_size);
>
> @@ -1357,7 +1366,7 @@ static int ad9467_probe(struct spi_device *spi)
> return ret;
>
> ret = devm_iio_backend_request_buffer(&spi->dev, st->back, indio_dev);
> - if (ret)
> + if (ret && ret != -EOPNOTSUPP)
> return ret;
>
> ret = devm_iio_backend_enable(&spi->dev, st->back);