[PATCH v3 2/4] iio: industrialio-backend: support backend capabilities

Tomas Melin posted 4 patches 3 weeks, 4 days ago
There is a newer version of this series
[PATCH v3 2/4] iio: industrialio-backend: support backend capabilities
Posted by Tomas Melin 3 weeks, 4 days ago
Not all backends support the full set of capabilities provided by the
industrialio-backend framework. Capability bits can be used in frontends
and backends for checking for a certain feature set, or if using
related functions can be expected to fail.

Capability bits should be set by a compatible backend and provided when
registering the backend.

Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
---
 drivers/iio/industrialio-backend.c | 17 +++++++++++++++++
 include/linux/iio/backend.h        | 17 +++++++++++++++++
 2 files changed, 34 insertions(+)

diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
index 447b694d6d5f72dc6f018b1697fdb88e555bd61e..0a98fdd5df9db6cc233af819ac5243ba8cd5266f 100644
--- a/drivers/iio/industrialio-backend.c
+++ b/drivers/iio/industrialio-backend.c
@@ -56,6 +56,7 @@ struct iio_backend {
 	void *priv;
 	const char *name;
 	unsigned int cached_reg_addr;
+	u32 caps;
 	/*
 	 * This index is relative to the frontend. Meaning that for
 	 * frontends with multiple backends, this will be the index of this
@@ -774,6 +775,21 @@ int iio_backend_extend_chan_spec(struct iio_backend *back,
 }
 EXPORT_SYMBOL_NS_GPL(iio_backend_extend_chan_spec, "IIO_BACKEND");
 
+/**
+ * iio_backend_has_caps - Check if backend has specific capabilities
+ * @back: Backend device
+ * @caps: Capabilities to check
+ *
+ * RETURNS:
+ * Non-zero value if backend has all the requested capabilities,
+ * 0 otherwise.
+ */
+int iio_backend_has_caps(struct iio_backend *back, u32 caps)
+{
+	return back->caps & caps;
+}
+EXPORT_SYMBOL_NS_GPL(iio_backend_has_caps, "IIO_BACKEND");
+
 static void iio_backend_release(void *arg)
 {
 	struct iio_backend *back = arg;
@@ -1114,6 +1130,7 @@ int devm_iio_backend_register(struct device *dev,
 
 	back->ops = info->ops;
 	back->name = info->name;
+	back->caps = info->caps;
 	back->owner = dev->driver->owner;
 	back->dev = dev;
 	back->priv = priv;
diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h
index 7f815f3fed6ae34c65ffc579d5101020fc9bd336..8a0df8e980e910ac2d5398275963dc5adf077c8a 100644
--- a/include/linux/iio/backend.h
+++ b/include/linux/iio/backend.h
@@ -84,6 +84,20 @@ enum iio_backend_filter_type {
 	IIO_BACKEND_FILTER_TYPE_MAX
 };
 
+/**
+ * enum iio_backend_capabilities - Backend capabilities
+ * Backend capabilities can be used by frontends to check if a given
+ * functionality is supported by the backend. Capabilities are loosely
+ * coupled with operations, meaning that a capability requires certain
+ * operations to be implemented by the backend.
+ * @IIO_BACKEND_CAP_CALIBRATION: Backend supports calibration. Needs at least
+ * iodelay_set(), test_pattern_set() data_sample_trigger(), chan_status()
+ * and data_format_set() operations implemented.
+ */
+enum iio_backend_capabilities {
+	IIO_BACKEND_CAP_CALIBRATION = BIT(0),
+};
+
 /**
  * struct iio_backend_ops - operations structure for an iio_backend
  * @enable: Enable backend.
@@ -179,10 +193,12 @@ struct iio_backend_ops {
  * struct iio_backend_info - info structure for an iio_backend
  * @name: Backend name.
  * @ops: Backend operations.
+ * @caps: Backend capabilities. @see iio_backend_capabilities
  */
 struct iio_backend_info {
 	const char *name;
 	const struct iio_backend_ops *ops;
+	u32 caps;
 };
 
 int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan);
@@ -235,6 +251,7 @@ int iio_backend_read_raw(struct iio_backend *back,
 			 long mask);
 int iio_backend_extend_chan_spec(struct iio_backend *back,
 				 struct iio_chan_spec *chan);
+int iio_backend_has_caps(struct iio_backend *back, u32 caps);
 void *iio_backend_get_priv(const struct iio_backend *conv);
 struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name);
 struct iio_backend *devm_iio_backend_fwnode_get(struct device *dev,

-- 
2.47.3
Re: [PATCH v3 2/4] iio: industrialio-backend: support backend capabilities
Posted by Nuno Sá 3 weeks, 4 days ago
On Wed, 2026-01-14 at 10:45 +0000, Tomas Melin wrote:
> Not all backends support the full set of capabilities provided by the
> industrialio-backend framework. Capability bits can be used in frontends
> and backends for checking for a certain feature set, or if using
> related functions can be expected to fail.
> 
> Capability bits should be set by a compatible backend and provided when
> registering the backend.
> 
> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
> ---
>  drivers/iio/industrialio-backend.c | 17 +++++++++++++++++
>  include/linux/iio/backend.h        | 17 +++++++++++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
> index 447b694d6d5f72dc6f018b1697fdb88e555bd61e..0a98fdd5df9db6cc233af819ac5243ba8cd5266f 100644
> --- a/drivers/iio/industrialio-backend.c
> +++ b/drivers/iio/industrialio-backend.c
> @@ -56,6 +56,7 @@ struct iio_backend {
>  	void *priv;
>  	const char *name;
>  	unsigned int cached_reg_addr;
> +	u32 caps;
>  	/*
>  	 * This index is relative to the frontend. Meaning that for
>  	 * frontends with multiple backends, this will be the index of this
> @@ -774,6 +775,21 @@ int iio_backend_extend_chan_spec(struct iio_backend *back,
>  }
>  EXPORT_SYMBOL_NS_GPL(iio_backend_extend_chan_spec, "IIO_BACKEND");
>  
> +/**
> + * iio_backend_has_caps - Check if backend has specific capabilities
> + * @back: Backend device
> + * @caps: Capabilities to check
> + *
> + * RETURNS:
> + * Non-zero value if backend has all the requested capabilities,
> + * 0 otherwise.
> + */
> +int iio_backend_has_caps(struct iio_backend *back, u32 caps)
> +{
> +	return back->caps & caps;
> +}
> +EXPORT_SYMBOL_NS_GPL(iio_backend_has_caps, "IIO_BACKEND");
> +
>  static void iio_backend_release(void *arg)
>  {
>  	struct iio_backend *back = arg;
> @@ -1114,6 +1130,7 @@ int devm_iio_backend_register(struct device *dev,
>  
>  	back->ops = info->ops;
>  	back->name = info->name;
> +	back->caps = info->caps;
>  	back->owner = dev->driver->owner;
>  	back->dev = dev;
>  	back->priv = priv;
> diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h
> index 7f815f3fed6ae34c65ffc579d5101020fc9bd336..8a0df8e980e910ac2d5398275963dc5adf077c8a 100644
> --- a/include/linux/iio/backend.h
> +++ b/include/linux/iio/backend.h
> @@ -84,6 +84,20 @@ enum iio_backend_filter_type {
>  	IIO_BACKEND_FILTER_TYPE_MAX
>  };
>  
> +/**
> + * enum iio_backend_capabilities - Backend capabilities
> + * Backend capabilities can be used by frontends to check if a given
> + * functionality is supported by the backend. Capabilities are loosely
> + * coupled with operations, meaning that a capability requires certain
> + * operations to be implemented by the backend.

We could also mention this is useful for frontends that are expected to
work with different backends which can offer different functionality.

- Nuno Sá

> + * @IIO_BACKEND_CAP_CALIBRATION: Backend supports calibration. Needs at least
> + * iodelay_set(), test_pattern_set() data_sample_trigger(), chan_status()
> + * and data_format_set() operations implemented.
> + */
> +enum iio_backend_capabilities {
> +	IIO_BACKEND_CAP_CALIBRATION = BIT(0),
> +};
> +
>  /**
>   * struct iio_backend_ops - operations structure for an iio_backend
>   * @enable: Enable backend.
> @@ -179,10 +193,12 @@ struct iio_backend_ops {
>   * struct iio_backend_info - info structure for an iio_backend
>   * @name: Backend name.
>   * @ops: Backend operations.
> + * @caps: Backend capabilities. @see iio_backend_capabilities
>   */
>  struct iio_backend_info {
>  	const char *name;
>  	const struct iio_backend_ops *ops;
> +	u32 caps;
>  };
>  
>  int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan);
> @@ -235,6 +251,7 @@ int iio_backend_read_raw(struct iio_backend *back,
>  			 long mask);
>  int iio_backend_extend_chan_spec(struct iio_backend *back,
>  				 struct iio_chan_spec *chan);
> +int iio_backend_has_caps(struct iio_backend *back, u32 caps);
>  void *iio_backend_get_priv(const struct iio_backend *conv);
>  struct iio_backend *devm_iio_backend_get(struct device *dev, const char *name);
>  struct iio_backend *devm_iio_backend_fwnode_get(struct device *dev,
Re: [PATCH v3 2/4] iio: industrialio-backend: support backend capabilities
Posted by Jonathan Cameron 3 weeks, 4 days ago
On Wed, 14 Jan 2026 10:45:51 +0000
Tomas Melin <tomas.melin@vaisala.com> wrote:

> Not all backends support the full set of capabilities provided by the
> industrialio-backend framework. Capability bits can be used in frontends
> and backends for checking for a certain feature set, or if using
> related functions can be expected to fail.
> 
> Capability bits should be set by a compatible backend and provided when
> registering the backend.
> 
> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
Hi Tomas,

One thing inline.

Thanks

Jonathan


> ---
>  drivers/iio/industrialio-backend.c | 17 +++++++++++++++++
>  include/linux/iio/backend.h        | 17 +++++++++++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
> index 447b694d6d5f72dc6f018b1697fdb88e555bd61e..0a98fdd5df9db6cc233af819ac5243ba8cd5266f 100644
> --- a/drivers/iio/industrialio-backend.c
> +++ b/drivers/iio/industrialio-backend.c
> @@ -56,6 +56,7 @@ struct iio_backend {
>  	void *priv;
>  	const char *name;
>  	unsigned int cached_reg_addr;
> +	u32 caps;
>  	/*
>  	 * This index is relative to the frontend. Meaning that for
>  	 * frontends with multiple backends, this will be the index of this
> @@ -774,6 +775,21 @@ int iio_backend_extend_chan_spec(struct iio_backend *back,
>  }
>  EXPORT_SYMBOL_NS_GPL(iio_backend_extend_chan_spec, "IIO_BACKEND");
>  
> +/**
> + * iio_backend_has_caps - Check if backend has specific capabilities
> + * @back: Backend device
> + * @caps: Capabilities to check
> + *
> + * RETURNS:
> + * Non-zero value if backend has all the requested capabilities,

It doesn't...   back->caps = 0x1, caps = 0x3 returns 0x1 which
is non-zero.   I'd do
return (back->caps & caps) == caps;

Though that also rather strongly indicates this would be better returning
a bool.


> + * 0 otherwise.
> + */
> +int iio_backend_has_caps(struct iio_backend *back, u32 caps)
> +{
> +	return back->caps & caps;
> +}
> +EXPORT_SYMBOL_NS_GPL(iio_backend_has_caps, "IIO_BACKEND");
Re: [PATCH v3 2/4] iio: industrialio-backend: support backend capabilities
Posted by Tomas Melin 3 weeks, 3 days ago
Hi,

On 14/01/2026 14:28, Jonathan Cameron wrote:
> On Wed, 14 Jan 2026 10:45:51 +0000
> Tomas Melin <tomas.melin@vaisala.com> wrote:
> 
>> Not all backends support the full set of capabilities provided by the
>> industrialio-backend framework. Capability bits can be used in frontends
>> and backends for checking for a certain feature set, or if using
>> related functions can be expected to fail.
>>
>> Capability bits should be set by a compatible backend and provided when
>> registering the backend.
>>
>> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
> Hi Tomas,
> 
> One thing inline.
> 
> Thanks
> 
> Jonathan
> 
> 
>> ---
>>  drivers/iio/industrialio-backend.c | 17 +++++++++++++++++
>>  include/linux/iio/backend.h        | 17 +++++++++++++++++
>>  2 files changed, 34 insertions(+)
>>
>> diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
>> index 447b694d6d5f72dc6f018b1697fdb88e555bd61e..0a98fdd5df9db6cc233af819ac5243ba8cd5266f 100644
>> --- a/drivers/iio/industrialio-backend.c
>> +++ b/drivers/iio/industrialio-backend.c
>> @@ -56,6 +56,7 @@ struct iio_backend {
>>  	void *priv;
>>  	const char *name;
>>  	unsigned int cached_reg_addr;
>> +	u32 caps;
>>  	/*
>>  	 * This index is relative to the frontend. Meaning that for
>>  	 * frontends with multiple backends, this will be the index of this
>> @@ -774,6 +775,21 @@ int iio_backend_extend_chan_spec(struct iio_backend *back,
>>  }
>>  EXPORT_SYMBOL_NS_GPL(iio_backend_extend_chan_spec, "IIO_BACKEND");
>>  
>> +/**
>> + * iio_backend_has_caps - Check if backend has specific capabilities
>> + * @back: Backend device
>> + * @caps: Capabilities to check
>> + *
>> + * RETURNS:
>> + * Non-zero value if backend has all the requested capabilities,
> 
> It doesn't...   back->caps = 0x1, caps = 0x3 returns 0x1 which
> is non-zero.   I'd do
> return (back->caps & caps) == caps;
> 
> Though that also rather strongly indicates this would be better returning
> a bool.

Thanks for pointing this out, will fix and change to boolean return value.

Thanks,
Tomas


> 
> 
>> + * 0 otherwise.
>> + */
>> +int iio_backend_has_caps(struct iio_backend *back, u32 caps)
>> +{
>> +	return back->caps & caps;
>> +}
>> +EXPORT_SYMBOL_NS_GPL(iio_backend_has_caps, "IIO_BACKEND");
> 
> 
>
Re: [PATCH v3 2/4] iio: industrialio-backend: support backend capabilities
Posted by Nuno Sá 3 weeks, 4 days ago
On Wed, 2026-01-14 at 10:45 +0000, Tomas Melin wrote:
> Not all backends support the full set of capabilities provided by the
> industrialio-backend framework. Capability bits can be used in frontends
> and backends for checking for a certain feature set, or if using
> related functions can be expected to fail.
> 
> Capability bits should be set by a compatible backend and provided when
> registering the backend.
> 
> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
> ---
>  drivers/iio/industrialio-backend.c | 17 +++++++++++++++++
>  include/linux/iio/backend.h        | 17 +++++++++++++++++
>  2 files changed, 34 insertions(+)
> 
> diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
> index 447b694d6d5f72dc6f018b1697fdb88e555bd61e..0a98fdd5df9db6cc233af819ac5243ba8cd5266f 100644
> --- a/drivers/iio/industrialio-backend.c
> +++ b/drivers/iio/industrialio-backend.c
> @@ -56,6 +56,7 @@ struct iio_backend {
>  	void *priv;
>  	const char *name;
>  	unsigned int cached_reg_addr;
> +	u32 caps;
>  	/*
>  	 * This index is relative to the frontend. Meaning that for
>  	 * frontends with multiple backends, this will be the index of this
> @@ -774,6 +775,21 @@ int iio_backend_extend_chan_spec(struct iio_backend *back,
>  }
>  EXPORT_SYMBOL_NS_GPL(iio_backend_extend_chan_spec, "IIO_BACKEND");
>  
> +/**
> + * iio_backend_has_caps - Check if backend has specific capabilities
> + * @back: Backend device
> + * @caps: Capabilities to check
> + *
> + * RETURNS:
> + * Non-zero value if backend has all the requested capabilities,
> + * 0 otherwise.
> + */
> +int iio_backend_has_caps(struct iio_backend *back, u32 caps)
> +{
> +	return back->caps & caps;
> +}
> +EXPORT_SYMBOL_NS_GPL(iio_backend_has_caps, "IIO_BACKEND");
> +
>  static void iio_backend_release(void *arg)
>  {
>  	struct iio_backend *back = arg;
> @@ -1114,6 +1130,7 @@ int devm_iio_backend_register(struct device *dev,
>  
>  	back->ops = info->ops;
>  	back->name = info->name;
> +	back->caps = info->caps;

It would be nice to sanity check the registered backend here. If it advertises some capability,
then better to support the corresponding op.

>  	back->owner = dev->driver->owner;
>  	back->dev = dev;
>  	back->priv = priv;
> diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h
> index 7f815f3fed6ae34c65ffc579d5101020fc9bd336..8a0df8e980e910ac2d5398275963dc5adf077c8a 100644
> --- a/include/linux/iio/backend.h
> +++ b/include/linux/iio/backend.h
> @@ -84,6 +84,20 @@ enum iio_backend_filter_type {
>  	IIO_BACKEND_FILTER_TYPE_MAX
>  };
>  
> +/**
> + * enum iio_backend_capabilities - Backend capabilities
> + * Backend capabilities can be used by frontends to check if a given
> + * functionality is supported by the backend. Capabilities are loosely
> + * coupled with operations, meaning that a capability requires certain
> + * operations to be implemented by the backend.
> + * @IIO_BACKEND_CAP_CALIBRATION: Backend supports calibration. Needs at least
> + * iodelay_set(), test_pattern_set() data_sample_trigger(), chan_status()
> + * and data_format_set() operations implemented.

I would not be so explicit as the above. It is very specific to the ad9467 process.
There are other devices with other ways of calibrating the interface and I don't want
people to keep adding things into the comment. So it needs to be a bit more generic
and we should also be more explicit about it being about calibrating the data interface.

> + */
> +enum iio_backend_capabilities {
> +	IIO_BACKEND_CAP_CALIBRATION = BIT(0),
> +};
> +
>  /**
>   * struct iio_backend_ops - operations structure for an iio_backend
>   * @enable: Enable backend.
> @@ -179,10 +193,12 @@ struct iio_backend_ops {
>   * struct iio_backend_info - info structure for an iio_backend
>   * @name: Backend name.
>   * @ops: Backend operations.
> + * @caps: Backend capabilities. @see iio_backend_capabilities
>   */
>  struct iio_backend_info {
>  	const char *name;
>  	const struct iio_backend_ops *ops;
> +	u32 caps;
>  };
>  
>  int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan);
> @@ -235,6 +251,7 @@ int iio_backend_read_raw(struct iio_backend *back,
>  			 long mask);
>  int iio_backend_extend_chan_spec(struct iio_backend *back,
>  				 struct iio_chan_spec *chan);
> +int iio_backend_has_caps(struct iio_backend *back, u32 caps);

Not what David suggested and I do agree with him FWIW.

- Nuno Sá
Re: [PATCH v3 2/4] iio: industrialio-backend: support backend capabilities
Posted by Tomas Melin 2 weeks, 6 days ago
Hi,

On 14/01/2026 14:20, Nuno Sá wrote:
> On Wed, 2026-01-14 at 10:45 +0000, Tomas Melin wrote:
>> Not all backends support the full set of capabilities provided by the
>> industrialio-backend framework. Capability bits can be used in frontends
>> and backends for checking for a certain feature set, or if using
>> related functions can be expected to fail.
>>
>> Capability bits should be set by a compatible backend and provided when
>> registering the backend.
>>
>> Signed-off-by: Tomas Melin <tomas.melin@vaisala.com>
>> ---
>>  drivers/iio/industrialio-backend.c | 17 +++++++++++++++++
>>  include/linux/iio/backend.h        | 17 +++++++++++++++++
>>  2 files changed, 34 insertions(+)
>>
>> diff --git a/drivers/iio/industrialio-backend.c b/drivers/iio/industrialio-backend.c
>> index 447b694d6d5f72dc6f018b1697fdb88e555bd61e..0a98fdd5df9db6cc233af819ac5243ba8cd5266f 100644
>> --- a/drivers/iio/industrialio-backend.c
>> +++ b/drivers/iio/industrialio-backend.c
>> @@ -56,6 +56,7 @@ struct iio_backend {
>>  	void *priv;
>>  	const char *name;
>>  	unsigned int cached_reg_addr;
>> +	u32 caps;
>>  	/*
>>  	 * This index is relative to the frontend. Meaning that for
>>  	 * frontends with multiple backends, this will be the index of this
>> @@ -774,6 +775,21 @@ int iio_backend_extend_chan_spec(struct iio_backend *back,
>>  }
>>  EXPORT_SYMBOL_NS_GPL(iio_backend_extend_chan_spec, "IIO_BACKEND");
>>  
>> +/**
>> + * iio_backend_has_caps - Check if backend has specific capabilities
>> + * @back: Backend device
>> + * @caps: Capabilities to check
>> + *
>> + * RETURNS:
>> + * Non-zero value if backend has all the requested capabilities,
>> + * 0 otherwise.
>> + */
>> +int iio_backend_has_caps(struct iio_backend *back, u32 caps)
>> +{
>> +	return back->caps & caps;
>> +}
>> +EXPORT_SYMBOL_NS_GPL(iio_backend_has_caps, "IIO_BACKEND");
>> +
>>  static void iio_backend_release(void *arg)
>>  {
>>  	struct iio_backend *back = arg;
>> @@ -1114,6 +1130,7 @@ int devm_iio_backend_register(struct device *dev,
>>  
>>  	back->ops = info->ops;
>>  	back->name = info->name;
>> +	back->caps = info->caps;
> 
> It would be nice to sanity check the registered backend here. If it advertises some capability,
> then better to support the corresponding op.
That might be easier said than done. A certain capability might map to
slightly different operations on different frontend/backend combinations.
Agree on general level but I would omit this check currently.

> 
>>  	back->owner = dev->driver->owner;
>>  	back->dev = dev;
>>  	back->priv = priv;
>> diff --git a/include/linux/iio/backend.h b/include/linux/iio/backend.h
>> index 7f815f3fed6ae34c65ffc579d5101020fc9bd336..8a0df8e980e910ac2d5398275963dc5adf077c8a 100644
>> --- a/include/linux/iio/backend.h
>> +++ b/include/linux/iio/backend.h
>> @@ -84,6 +84,20 @@ enum iio_backend_filter_type {
>>  	IIO_BACKEND_FILTER_TYPE_MAX
>>  };
>>  
>> +/**
>> + * enum iio_backend_capabilities - Backend capabilities
>> + * Backend capabilities can be used by frontends to check if a given
>> + * functionality is supported by the backend. Capabilities are loosely
>> + * coupled with operations, meaning that a capability requires certain
>> + * operations to be implemented by the backend.
>> + * @IIO_BACKEND_CAP_CALIBRATION: Backend supports calibration. Needs at least
>> + * iodelay_set(), test_pattern_set() data_sample_trigger(), chan_status()
>> + * and data_format_set() operations implemented.
> 
> I would not be so explicit as the above. It is very specific to the ad9467 process.
> There are other devices with other ways of calibrating the interface and I don't want
> people to keep adding things into the comment. So it needs to be a bit more generic
> and we should also be more explicit about it being about calibrating the data interface.
Agreed, I will update the text.

> 
>> + */
>> +enum iio_backend_capabilities {
>> +	IIO_BACKEND_CAP_CALIBRATION = BIT(0),
>> +};
>> +
>>  /**
>>   * struct iio_backend_ops - operations structure for an iio_backend
>>   * @enable: Enable backend.
>> @@ -179,10 +193,12 @@ struct iio_backend_ops {
>>   * struct iio_backend_info - info structure for an iio_backend
>>   * @name: Backend name.
>>   * @ops: Backend operations.
>> + * @caps: Backend capabilities. @see iio_backend_capabilities
>>   */
>>  struct iio_backend_info {
>>  	const char *name;
>>  	const struct iio_backend_ops *ops;
>> +	u32 caps;
>>  };
>>  
>>  int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan);
>> @@ -235,6 +251,7 @@ int iio_backend_read_raw(struct iio_backend *back,
>>  			 long mask);
>>  int iio_backend_extend_chan_spec(struct iio_backend *back,
>>  				 struct iio_chan_spec *chan);
>> +int iio_backend_has_caps(struct iio_backend *back, u32 caps);
> 
> Not what David suggested and I do agree with him FWIW.
AFAIU this was exactly what was suggested. Citing:

>> bool iio_backend_has_capabilities(struct iio_backend *back, u32 flags)
>> (caps is fine too if we want to keep it short)

Using the longer format is not very practial. Can we keep it as

iio_backend_has_caps ?


Thanks,
Tomas


> 
> - Nuno Sá

Re: [PATCH v3 2/4] iio: industrialio-backend: support backend capabilities
Posted by David Lechner 2 weeks, 6 days ago
On 1/19/26 7:49 AM, Tomas Melin wrote:

...

>>>  int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan);
>>> @@ -235,6 +251,7 @@ int iio_backend_read_raw(struct iio_backend *back,
>>>  			 long mask);
>>>  int iio_backend_extend_chan_spec(struct iio_backend *back,
>>>  				 struct iio_chan_spec *chan);
>>> +int iio_backend_has_caps(struct iio_backend *back, u32 caps);
>>
>> Not what David suggested and I do agree with him FWIW.
> AFAIU this was exactly what was suggested. Citing:

Slight difference. Should return bool instead of int.

> 
>>> bool iio_backend_has_capabilities(struct iio_backend *back, u32 flags)
>>> (caps is fine too if we want to keep it short)
> 
> Using the longer format is not very practical. Can we keep it as
> iio_backend_has_caps ?

Yes, I said as much already. But I guess you are asking Nuno. ;-)
Re: [PATCH v3 2/4] iio: industrialio-backend: support backend capabilities
Posted by Tomas Melin 2 weeks, 5 days ago
Hi,

On 19/01/2026 17:00, David Lechner wrote:
> On 1/19/26 7:49 AM, Tomas Melin wrote:
> 
> ...
> 
>>>>  int iio_backend_chan_enable(struct iio_backend *back, unsigned int chan);
>>>> @@ -235,6 +251,7 @@ int iio_backend_read_raw(struct iio_backend *back,
>>>>  			 long mask);
>>>>  int iio_backend_extend_chan_spec(struct iio_backend *back,
>>>>  				 struct iio_chan_spec *chan);
>>>> +int iio_backend_has_caps(struct iio_backend *back, u32 caps);
>>>
>>> Not what David suggested and I do agree with him FWIW.
>> AFAIU this was exactly what was suggested. Citing:
> 
> Slight difference. Should return bool instead of int.
Yes absolutely, perhaps it was about the signature. That is on the
change list for next version.

Thanks,
Tomas

> 
>>
>>>> bool iio_backend_has_capabilities(struct iio_backend *back, u32 flags)
>>>> (caps is fine too if we want to keep it short)
>>
>> Using the longer format is not very practical. Can we keep it as
>> iio_backend_has_caps ?
> 
> Yes, I said as much already. But I guess you are asking Nuno. ;-)