mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tomas Melin <tomas.melin@vaisala.com>
To: "Jonathan Cameron" <jic23@kernel.org>, "Nuno Sá" <noname.nuno@gmail.com>
Cc: Michael Hennerich <Michael.Hennerich@analog.com>,
	Nuno Sa <nuno.sa@analog.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	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: Mon, 19 Jan 2026 13:55:08 +0200	[thread overview]
Message-ID: <fdc20647-671b-4ba8-a30a-50e46ac71c6e@vaisala.com> (raw)
In-Reply-To: <20260116183212.08630389@jic23-huawei>



On 16/01/2026 20:32, Jonathan Cameron wrote:
> On Thu, 15 Jan 2026 11:54:28 +0000
> Nuno Sá <noname.nuno@gmail.com> wrote:
> 
>> On Wed, 2026-01-14 at 17:23 +0200, Tomas Melin wrote:
>>> Hi,
>>>
>>> On 14/01/2026 14:29, Nuno Sá wrote:  
>>>> 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.
>>>>>   
>>>   
>>>>> +		return 0;
>>>>> +  
>>>>
>>>> As David suggested, it might make more sense to do the check from the callers. Not as
>>>> important as within the backend functions though.
>>>>   
>>>>>  	/* 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;  
>>>>
>>>> Don't agree with the above. I would prefer to see a dedicated CAP for buffering
>>>> otherwise I would argue why not doing the same for everything? While it might
>>>> be acceptable merging IIO_BACKEND_CAP_TEST_PATTERNS and IIO_BACKEND_CAP_CALIBRATION
>>>> (given they are related to some extent), that does not apply to buffering.  
>>>
>>> Okay perhaps we first need to agree on how we define a capability;)
>>>
>>> So my thinking here was that calibration capability expands across
>>> several or even many op calls, so it's a feature level thing and
>>> requires several coordinated functions. So does the test pattern, but
>>> it's a sub entity of the calibration so I merged the two together. So
>>> checking for a capability in these cases makes sense, since checking
>>> against a single operation call for determining if the capability is
>>> present is not easy and which function would it be, etc.  
>>
>> Makes sense.
>>
>>>
>>> The backend buffer on the other hand maps to a single op call (in theory
>>> two). So checking for that buffering capability can be done by checking
>>> if the op call is supported (eopnotsupp). I was kindof thinking that why
>>> need a capability if the mapping is 1:1 and the information is available
>>> through that error value directly?  
>>
>> Yeah, TBH the only reason I can think of is readability. To me, it is more
>> explicit:
>>
>> if (has_buffering())
>> 	request_buffer(); //not allowed to fail
>>
>> And can be a bit confusing having a mix of has_capability() and checking for
>> error codes.
>>
>> But yes, checking for specific error codes for determining behavior is a common
>> pattern so I won't be nitpicky about it.
> 
> I'd prefer capabilities for each thing rather than a mixed scheme.
> Nothing wrong with also returning -ENOTSUPP if someone doesn't check
> the capability first as that's still helpful for debug.

Okay I'll update accordingly. So capabilities are defined as being
something that

* is defined/added on a need basis to help frontends decide if a feature
is supported
* can map into multiple operations
* can map to a single operation

Thanks,
Tomas



> 
> 
>>
>>>
>>> On frontend level, like here it is known that the driver can function
>>> without that buffering, so if the backend does not supported it can be
>>> okay to proceed.
>>> If we add a capability for a single operation that has 1:1 mapping then
>>> basically we should map all and that is not really the point?  
>>
>>> I see the capability like a contract between the backend and frontend on
>>> feature level, that the feature is there but the implementation of a
>>> specific capability might actually differ depending on the use case
>>> (like we see with ad9467 and ad485x calibration and their backends)
>>>
>>> What are your thoughts about this?
>>>   
>>
>> Ok, I think it makes sense to me but maybe we should be more explicit/clear in
>> the docs:
>>
>> "... meaning that a capability requires certain 
>> operations to be implemented by the backend"
>>
>> Maybe s/certain/multiple and we could even mention that if a frontend is interested
>> in knowing that a operation is not supported, the error code can be checked
>> (though this could be obvious already).
>>
>> Let's see what Jonathan and others thinks about it.
>>
>> - Nuno Sá
>>
>>
>>
>>
>>
>>
> 
> 


  reply	other threads:[~2026-01-19 11:55 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 [this message]
2026-01-14 12:45   ` Jonathan Cameron
2026-01-14 15:24     ` Tomas Melin
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=fdc20647-671b-4ba8-a30a-50e46ac71c6e@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=lars@metafoo.de \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=noname.nuno@gmail.com \
    --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®