From: Tomas Melin <tomas.melin@vaisala.com>
To: Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>,
Nuno Sa <nuno.sa@analog.com>,
Lars-Peter Clausen <lars@metafoo.de>,
Jonathan Cameron <jic23@kernel.org>,
David Lechner <dlechner@baylibre.com>,
Andy Shevchenko <andy@kernel.org>,
Olivier Moysan <olivier.moysan@foss.st.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 4/4] iio: adc: ad9467: check for backend capabilities
Date: Wed, 14 Jan 2026 17:24:23 +0200 [thread overview]
Message-ID: <4b84e4ec-7d42-4a77-b521-cb41a8623a24@vaisala.com> (raw)
In-Reply-To: <20260114124527.00000344@huawei.com>
Hi,
On 14/01/2026 14:45, Jonathan Cameron wrote:
> On Wed, 14 Jan 2026 10:45:53 +0000
> Tomas Melin <tomas.melin@vaisala.com> 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@vaisala.com>
> Hi Tomas,
>
> A few comments inline around when we should or should not return errors.
>
>> ---
>> 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;
>
> If it isn't supported then isn't any attempt to turn test_mode on an error?
> I would return errors from all these calls and only decide it doesn't
> matter right at the top of the call stack.
I was considering this option too, I will change accordingly.
>
> In this particular case that's either calibration mode stuff (covered by check
> below) or ad9467_chan_test_mod_write() I'd just add a top level check there
> on ability to do calibration. Alternative would be to not register the debugfs
> at all. Challenge is that is a small ABI break. Do we care? If we had
> been doing this from the start we would have just hidden the pointless
> interface.
> (Key is we can change userspace interfaces, as long no one notices!)
The testmodes from device side should still at least be there, only a
few of the modes currently have a backend mode, too.
>
>> +
>> 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;
>
> So this the idea of a stub calibration bothers me a little, but I think
> it's more acceptable to do it for this top level call. So keep this one, but
> all the others look to me like they should be returning errors.
OK
>
>> +
>> /* 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)
>
> I don't see any modification of devm_iio_backend_request_buffer() in this
> set so why why is it now acceptable to return not supported?
> Given the capabilities stuff added, should this not be another capability
> we check before trying to request the buffer?
Basically because I reasoned that capabilities are more like features
rather than single operation. The single operation tells if the
capability is there. I reasoned a bit more about this in a related
answer replying to Nuno, hopefully you find time to read that
explanation and provide your thoughts.
And reason it would now be acceptable is that the original code does not
account for any optional features within the backends, but now it does.
It knows it can work without the buffering, and the return value can
tell if it is supported or not.
Thanks,
Tomas
>
>> return ret;
>>
>> ret = devm_iio_backend_enable(&spi->dev, st->back);
>>
>
next prev parent reply other threads:[~2026-01-14 15:24 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-14 10:45 [PATCH v3 0/4] iio: adc: ad9467: Support alternative backends Tomas Melin
2026-01-14 10:45 ` [PATCH v3 1/4] iio: adc: ad9467: include two's complement in default mode Tomas Melin
2026-01-16 18:39 ` Jonathan Cameron
2026-01-14 10:45 ` [PATCH v3 2/4] iio: industrialio-backend: support backend capabilities Tomas Melin
2026-01-14 12:20 ` Nuno Sá
2026-01-19 13:49 ` Tomas Melin
2026-01-19 15:00 ` David Lechner
2026-01-20 6:45 ` Tomas Melin
2026-01-14 12:28 ` Jonathan Cameron
2026-01-15 7:48 ` Tomas Melin
2026-01-14 13:19 ` Nuno Sá
2026-01-14 10:45 ` [PATCH v3 3/4] iio: adc: adi-axi-adc: define supported iio-backend capabilities Tomas Melin
2026-01-14 10:45 ` [PATCH v3 4/4] iio: adc: ad9467: check for backend capabilities Tomas Melin
2026-01-14 12:29 ` Nuno Sá
2026-01-14 15:23 ` Tomas Melin
2026-01-15 11:54 ` Nuno Sá
2026-01-16 18:32 ` Jonathan Cameron
2026-01-19 11:55 ` Tomas Melin
2026-01-14 12:45 ` Jonathan Cameron
2026-01-14 15:24 ` Tomas Melin [this message]
2026-01-14 13:38 ` Nuno Sá
2026-01-14 13:32 ` [PATCH v3 0/4] iio: adc: ad9467: Support alternative backends Nuno Sá
2026-01-14 15:32 ` Tomas Melin
2026-01-15 12:04 ` Nuno Sá
2026-01-15 13:30 ` Tomas Melin
2026-01-16 13:31 ` Nuno Sá
2026-01-16 18:37 ` Jonathan Cameron
2026-01-18 9:21 ` Nuno Sá
2026-01-20 11:01 ` Tomas Melin
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=4b84e4ec-7d42-4a77-b521-cb41a8623a24@vaisala.com \
--to=tomas.melin@vaisala.com \
--cc=Michael.Hennerich@analog.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=olivier.moysan@foss.st.com \
/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
all inboxes | Powered by JetHome®