Linux Documentation
 help / color / mirror / Atom feed
* [PATCH v7 2/6] iio: Replace 'sign' field with union in struct iio_scan_type
       [not found] <20260304080519.2844101-1-flavra@baylibre.com>
@ 2026-03-04  8:06 ` Francesco Lavra
  2026-03-04 22:55   ` David Lechner
  2026-03-07 13:10   ` Jonathan Cameron
  2026-03-04  8:06 ` [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements Francesco Lavra
  1 sibling, 2 replies; 12+ messages in thread
From: Francesco Lavra @ 2026-03-04  8:06 UTC (permalink / raw)
  To: Jonathan Corbet, Shuah Khan, Jonathan Cameron, David Lechner,
	Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio

This field is used to differentiate between signed and unsigned integers.
A following commit will extend its use in order to add support for non-
integer scan elements; therefore, replace it with a union that contains a
more generic 'format' field. This union will be dropped when all drivers
are changed to use the format field.

Signed-off-by: Francesco Lavra <flavra@baylibre.com>
---
 Documentation/driver-api/iio/buffers.rst | 4 ++--
 include/linux/iio/iio.h                  | 7 +++++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst
index 63f364e862d1..f36e6d00173f 100644
--- a/Documentation/driver-api/iio/buffers.rst
+++ b/Documentation/driver-api/iio/buffers.rst
@@ -78,7 +78,7 @@ fields in iio_chan_spec definition::
    /* other members */
            int scan_index
            struct {
-                   char sign;
+                   char format;
                    u8 realbits;
                    u8 storagebits;
                    u8 shift;
@@ -98,7 +98,7 @@ following channel definition::
 		   /* other stuff here */
 		   .scan_index = 0,
 		   .scan_type = {
-		           .sign = 's',
+		           .format = 's',
 			   .realbits = 12,
 			   .storagebits = 16,
 			   .shift = 4,
diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
index a9ecff191bd9..61f1dfc14e02 100644
--- a/include/linux/iio/iio.h
+++ b/include/linux/iio/iio.h
@@ -178,7 +178,7 @@ struct iio_event_spec {
 
 /**
  * struct iio_scan_type - specification for channel data format in buffer
- * @sign:		's' or 'u' to specify signed or unsigned
+ * @format:		(signed or unsigned) integer, or floating point
  * @realbits:		Number of valid bits of data
  * @storagebits:	Realbits + padding
  * @shift:		Shift right by this before masking out realbits.
@@ -189,7 +189,10 @@ struct iio_event_spec {
  * @endianness:		little or big endian
  */
 struct iio_scan_type {
-	char	sign;
+	union {
+		char sign;
+		char format;
+	};
 	u8	realbits;
 	u8	storagebits;
 	u8	shift;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements
       [not found] <20260304080519.2844101-1-flavra@baylibre.com>
  2026-03-04  8:06 ` [PATCH v7 2/6] iio: Replace 'sign' field with union in struct iio_scan_type Francesco Lavra
@ 2026-03-04  8:06 ` Francesco Lavra
  2026-03-04 22:45   ` David Lechner
  1 sibling, 1 reply; 12+ messages in thread
From: Francesco Lavra @ 2026-03-04  8:06 UTC (permalink / raw)
  To: Jonathan Cameron, David Lechner, Nuno Sá, Andy Shevchenko,
	Jonathan Corbet, Shuah Khan, linux-iio, linux-kernel, linux-doc

In the data storage description of a scan element, the first character
after the colon can have the values 's' and 'u' to specify signed and
unsigned integers, respectively.
Add 'f' as an allowed value to specify floating-point numbers formatted
according to the IEEE 754 standard.

Signed-off-by: Francesco Lavra <flavra@baylibre.com>
---
 Documentation/ABI/testing/sysfs-bus-iio  | 33 +++++++++++++-----------
 Documentation/driver-api/iio/buffers.rst |  3 ++-
 Documentation/iio/iio_devbuf.rst         |  3 ++-
 3 files changed, 22 insertions(+), 17 deletions(-)

diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index 5f87dcee78f7..bd6c3305dd2b 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -1510,21 +1510,24 @@ Contact:	linux-iio@vger.kernel.org
 Description:
 		Description of the scan element data storage within the buffer
 		and hence the form in which it is read from user-space.
-		Form is [be|le]:[s|u]bits/storagebits[>>shift].
-		be or le specifies big or little endian. s or u specifies if
-		signed (2's complement) or unsigned. bits is the number of bits
-		of data and storagebits is the space (after padding) that it
-		occupies in the buffer. shift if specified, is the shift that
-		needs to be applied prior to masking out unused bits. Some
-		devices put their data in the middle of the transferred elements
-		with additional information on both sides.  Note that some
-		devices will have additional information in the unused bits
-		so to get a clean value, the bits value must be used to mask
-		the buffer output value appropriately.  The storagebits value
-		also specifies the data alignment.  So s48/64>>2 will be a
-		signed 48 bit integer stored in a 64 bit location aligned to
-		a 64 bit boundary. To obtain the clean value, shift right 2
-		and apply a mask to zero the top 16 bits of the result.
+		Form is [be|le]:[f|s|u]bits/storagebits[>>shift].
+		be or le specifies big or little endian. f means floating-point
+		(IEEE 754 binary format), s means signed (2's complement), u means
+		unsigned. bits is the number of bits of data and storagebits is the
+		space (after padding) that it occupies in the buffer; when using a
+		floating-point format, bits must be one of the width values defined
+		in the IEEE 754 standard for binary interchange formats (e.g. 16
+		indicates the binary16 format for half-precision numbers). shift,
+		if specified, is the shift that needs to be applied prior to
+		masking out unused bits. Some devices put their data in the middle
+		of the transferred elements with additional information on both
+		sides. Note that some devices will have additional information in
+		the unused bits, so to get a clean value the bits value must be
+		used to mask the buffer output value appropriately. The storagebits
+		value also specifies the data alignment. So s48/64>>2 will be a
+		signed 48 bit integer stored in a 64 bit location aligned to a 64
+		bit boundary. To obtain the clean value, shift right 2 and apply a
+		mask to zero the top 16 bits of the result.
 		For other storage combinations this attribute will be extended
 		appropriately.
 
diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst
index f36e6d00173f..2fc9c2951a9d 100644
--- a/Documentation/driver-api/iio/buffers.rst
+++ b/Documentation/driver-api/iio/buffers.rst
@@ -37,9 +37,10 @@ directory contains attributes of the following form:
 * :file:`index`, the scan_index of the channel.
 * :file:`type`, description of the scan element data storage within the buffer
   and hence the form in which it is read from user space.
-  Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift] .
+  Format is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift] .
 
   * *be* or *le*, specifies big or little endian.
+  * *f*, specifies if floating-point.
   * *s* or *u*, specifies if signed (2's complement) or unsigned.
   * *bits*, is the number of valid data bits.
   * *storagebits*, is the number of bits (after padding) that it occupies in the
diff --git a/Documentation/iio/iio_devbuf.rst b/Documentation/iio/iio_devbuf.rst
index dca1f0200b0d..e91730fa3cea 100644
--- a/Documentation/iio/iio_devbuf.rst
+++ b/Documentation/iio/iio_devbuf.rst
@@ -83,9 +83,10 @@ and the relevant _type attributes to establish the data storage format.
 
 Read-only attribute containing the description of the scan element data storage
 within the buffer and hence the form in which it is read from userspace. Format
-is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where:
+is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where:
 
 - **be** or **le** specifies big or little-endian.
+- **f** specifies if floating-point.
 - **s** or **u** specifies if signed (2's complement) or unsigned.
 - **bits** is the number of valid data bits.
 - **storagebits** is the number of bits (after padding) that it occupies in the
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements
  2026-03-04  8:06 ` [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements Francesco Lavra
@ 2026-03-04 22:45   ` David Lechner
  2026-03-05  9:09     ` Francesco Lavra
  0 siblings, 1 reply; 12+ messages in thread
From: David Lechner @ 2026-03-04 22:45 UTC (permalink / raw)
  To: Francesco Lavra, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
	Jonathan Corbet, Shuah Khan, linux-iio, linux-kernel, linux-doc

On 3/4/26 2:06 AM, Francesco Lavra wrote:
> In the data storage description of a scan element, the first character
> after the colon can have the values 's' and 'u' to specify signed and
> unsigned integers, respectively.
> Add 'f' as an allowed value to specify floating-point numbers formatted
> according to the IEEE 754 standard.
> 
...

> diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst
> index f36e6d00173f..2fc9c2951a9d 100644
> --- a/Documentation/driver-api/iio/buffers.rst
> +++ b/Documentation/driver-api/iio/buffers.rst
> @@ -37,9 +37,10 @@ directory contains attributes of the following form:
>  * :file:`index`, the scan_index of the channel.
>  * :file:`type`, description of the scan element data storage within the buffer
>    and hence the form in which it is read from user space.
> -  Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift] .
> +  Format is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift] .
>  
>    * *be* or *le*, specifies big or little endian.
> +  * *f*, specifies if floating-point.
>    * *s* or *u*, specifies if signed (2's complement) or unsigned.

I would keep all of the format options on one bullet point.

>    * *bits*, is the number of valid data bits.
>    * *storagebits*, is the number of bits (after padding) that it occupies in the
> diff --git a/Documentation/iio/iio_devbuf.rst b/Documentation/iio/iio_devbuf.rst
> index dca1f0200b0d..e91730fa3cea 100644
> --- a/Documentation/iio/iio_devbuf.rst
> +++ b/Documentation/iio/iio_devbuf.rst
> @@ -83,9 +83,10 @@ and the relevant _type attributes to establish the data storage format.
>  
>  Read-only attribute containing the description of the scan element data storage
>  within the buffer and hence the form in which it is read from userspace. Format
> -is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where:
> +is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where:
>  
>  - **be** or **le** specifies big or little-endian.
> +- **f** specifies if floating-point.
>  - **s** or **u** specifies if signed (2's complement) or unsigned.

same here

>  - **bits** is the number of valid data bits.
>  - **storagebits** is the number of bits (after padding) that it occupies in the


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 2/6] iio: Replace 'sign' field with union in struct iio_scan_type
  2026-03-04  8:06 ` [PATCH v7 2/6] iio: Replace 'sign' field with union in struct iio_scan_type Francesco Lavra
@ 2026-03-04 22:55   ` David Lechner
  2026-03-07 12:47     ` Jonathan Cameron
  2026-03-07 13:10   ` Jonathan Cameron
  1 sibling, 1 reply; 12+ messages in thread
From: David Lechner @ 2026-03-04 22:55 UTC (permalink / raw)
  To: Francesco Lavra, Jonathan Corbet, Shuah Khan, Jonathan Cameron,
	Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio

On 3/4/26 2:06 AM, Francesco Lavra wrote:
> This field is used to differentiate between signed and unsigned integers.
> A following commit will extend its use in order to add support for non-
> integer scan elements; therefore, replace it with a union that contains a
> more generic 'format' field. This union will be dropped when all drivers
> are changed to use the format field.
> 
> Signed-off-by: Francesco Lavra <flavra@baylibre.com>
> ---
>  Documentation/driver-api/iio/buffers.rst | 4 ++--
>  include/linux/iio/iio.h                  | 7 +++++--
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst
> index 63f364e862d1..f36e6d00173f 100644
> --- a/Documentation/driver-api/iio/buffers.rst
> +++ b/Documentation/driver-api/iio/buffers.rst
> @@ -78,7 +78,7 @@ fields in iio_chan_spec definition::
>     /* other members */
>             int scan_index
>             struct {
> -                   char sign;
> +                   char format;
>                     u8 realbits;
>                     u8 storagebits;
>                     u8 shift;
> @@ -98,7 +98,7 @@ following channel definition::
>  		   /* other stuff here */
>  		   .scan_index = 0,
>  		   .scan_type = {
> -		           .sign = 's',
> +		           .format = 's',
>  			   .realbits = 12,
>  			   .storagebits = 16,
>  			   .shift = 4,
> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> index a9ecff191bd9..61f1dfc14e02 100644
> --- a/include/linux/iio/iio.h
> +++ b/include/linux/iio/iio.h
> @@ -178,7 +178,7 @@ struct iio_event_spec {
>  
>  /**
>   * struct iio_scan_type - specification for channel data format in buffer
> - * @sign:		's' or 'u' to specify signed or unsigned
> + * @format:		(signed or unsigned) integer, or floating point

We should keep the list of valid values here.

>   * @realbits:		Number of valid bits of data
>   * @storagebits:	Realbits + padding
>   * @shift:		Shift right by this before masking out realbits.
> @@ -189,7 +189,10 @@ struct iio_event_spec {
>   * @endianness:		little or big endian
>   */
>  struct iio_scan_type {
> -	char	sign;
> +	union {
> +		char sign;
> +		char format;

Could add some comments here to say that format should be used
in new code and sign will be removed eventually.

> +	};
>  	u8	realbits;
>  	u8	storagebits;
>  	u8	shift;


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements
  2026-03-04 22:45   ` David Lechner
@ 2026-03-05  9:09     ` Francesco Lavra
  2026-03-05  9:23       ` Andy Shevchenko
  0 siblings, 1 reply; 12+ messages in thread
From: Francesco Lavra @ 2026-03-05  9:09 UTC (permalink / raw)
  To: David Lechner, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
	Jonathan Corbet, Shuah Khan, linux-iio, linux-kernel, linux-doc

On Wed, 2026-03-04 at 16:45 -0600, David Lechner wrote:
> On 3/4/26 2:06 AM, Francesco Lavra wrote:
> > In the data storage description of a scan element, the first character
> > after the colon can have the values 's' and 'u' to specify signed and
> > unsigned integers, respectively.
> > Add 'f' as an allowed value to specify floating-point numbers formatted
> > according to the IEEE 754 standard.
> > 
> ...
> 
> > diff --git a/Documentation/driver-api/iio/buffers.rst
> > b/Documentation/driver-api/iio/buffers.rst
> > index f36e6d00173f..2fc9c2951a9d 100644
> > --- a/Documentation/driver-api/iio/buffers.rst
> > +++ b/Documentation/driver-api/iio/buffers.rst
> > @@ -37,9 +37,10 @@ directory contains attributes of the following form:
> >  * :file:`index`, the scan_index of the channel.
> >  * :file:`type`, description of the scan element data storage within
> > the buffer
> >    and hence the form in which it is read from user space.
> > -  Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift] .
> > +  Format is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift] .
> >  
> >    * *be* or *le*, specifies big or little endian.
> > +  * *f*, specifies if floating-point.
> >    * *s* or *u*, specifies if signed (2's complement) or unsigned.
> 
> I would keep all of the format options on one bullet point.

That's what I did initially, but Andy suggested doing differently [1].


> >    * *bits*, is the number of valid data bits.
> >    * *storagebits*, is the number of bits (after padding) that it
> > occupies in the
> > diff --git a/Documentation/iio/iio_devbuf.rst
> > b/Documentation/iio/iio_devbuf.rst
> > index dca1f0200b0d..e91730fa3cea 100644
> > --- a/Documentation/iio/iio_devbuf.rst
> > +++ b/Documentation/iio/iio_devbuf.rst
> > @@ -83,9 +83,10 @@ and the relevant _type attributes to establish the
> > data storage format.
> >  
> >  Read-only attribute containing the description of the scan element
> > data storage
> >  within the buffer and hence the form in which it is read from
> > userspace. Format
> > -is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where:
> > +is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where:
> >  
> >  - **be** or **le** specifies big or little-endian.
> > +- **f** specifies if floating-point.
> >  - **s** or **u** specifies if signed (2's complement) or unsigned.
> 
> same here

[1] https://lore.kernel.org/linux-iio/aZ7dCdLs5xcJ4UGW@smile.fi.intel.com/
> 

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements
  2026-03-05  9:09     ` Francesco Lavra
@ 2026-03-05  9:23       ` Andy Shevchenko
  2026-03-05 14:37         ` David Lechner
  0 siblings, 1 reply; 12+ messages in thread
From: Andy Shevchenko @ 2026-03-05  9:23 UTC (permalink / raw)
  To: Francesco Lavra
  Cc: David Lechner, Jonathan Cameron, Nuno Sá, Andy Shevchenko,
	Jonathan Corbet, Shuah Khan, linux-iio, linux-kernel, linux-doc

On Thu, Mar 5, 2026 at 11:09 AM Francesco Lavra <flavra@baylibre.com> wrote:
> On Wed, 2026-03-04 at 16:45 -0600, David Lechner wrote:
> > On 3/4/26 2:06 AM, Francesco Lavra wrote:
> > > In the data storage description of a scan element, the first character
> > > after the colon can have the values 's' and 'u' to specify signed and
> > > unsigned integers, respectively.
> > > Add 'f' as an allowed value to specify floating-point numbers formatted
> > > according to the IEEE 754 standard.

...

> > > -  Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift] .
> > > +  Format is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift] .
> > >
> > >    * *be* or *le*, specifies big or little endian.
> > > +  * *f*, specifies if floating-point.
> > >    * *s* or *u*, specifies if signed (2's complement) or unsigned.
> >
> > I would keep all of the format options on one bullet point.
>
> That's what I did initially, but Andy suggested doing differently [1].

And still I think it's better to not mix them. The floating in the
same sentence is confusing (along with 2's complement mention and
sign).

...

> > > -is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where:
> > > +is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where:
> > >
> > >  - **be** or **le** specifies big or little-endian.
> > > +- **f** specifies if floating-point.
> > >  - **s** or **u** specifies if signed (2's complement) or unsigned.
> >
> > same here
>
> [1] https://lore.kernel.org/linux-iio/aZ7dCdLs5xcJ4UGW@smile.fi.intel.com/

Same here.

-- 
With Best Regards,
Andy Shevchenko

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements
  2026-03-05  9:23       ` Andy Shevchenko
@ 2026-03-05 14:37         ` David Lechner
  2026-03-06 12:09           ` Andy Shevchenko
  0 siblings, 1 reply; 12+ messages in thread
From: David Lechner @ 2026-03-05 14:37 UTC (permalink / raw)
  To: Andy Shevchenko, Francesco Lavra
  Cc: Jonathan Cameron, Nuno Sá, Andy Shevchenko, Jonathan Corbet,
	Shuah Khan, linux-iio, linux-kernel, linux-doc

On 3/5/26 3:23 AM, Andy Shevchenko wrote:
> On Thu, Mar 5, 2026 at 11:09 AM Francesco Lavra <flavra@baylibre.com> wrote:
>> On Wed, 2026-03-04 at 16:45 -0600, David Lechner wrote:
>>> On 3/4/26 2:06 AM, Francesco Lavra wrote:
>>>> In the data storage description of a scan element, the first character
>>>> after the colon can have the values 's' and 'u' to specify signed and
>>>> unsigned integers, respectively.
>>>> Add 'f' as an allowed value to specify floating-point numbers formatted
>>>> according to the IEEE 754 standard.
> 
> ...
> 
>>>> -  Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift] .
>>>> +  Format is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift] .
>>>>
>>>>    * *be* or *le*, specifies big or little endian.
>>>> +  * *f*, specifies if floating-point.
>>>>    * *s* or *u*, specifies if signed (2's complement) or unsigned.
>>>
>>> I would keep all of the format options on one bullet point.
>>
>> That's what I did initially, but Andy suggested doing differently [1].
> 
> And still I think it's better to not mix them. The floating in the
> same sentence is confusing (along with 2's complement mention and
> sign).

Then I would split up all 3. It is strange to mix some and not
all.

> 
> ...
> 
>>>> -is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where:
>>>> +is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where:
>>>>
>>>>  - **be** or **le** specifies big or little-endian.
>>>> +- **f** specifies if floating-point.
>>>>  - **s** or **u** specifies if signed (2's complement) or unsigned.
>>>
>>> same here
>>
>> [1] https://lore.kernel.org/linux-iio/aZ7dCdLs5xcJ4UGW@smile.fi.intel.com/
> 
> Same here.
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements
  2026-03-05 14:37         ` David Lechner
@ 2026-03-06 12:09           ` Andy Shevchenko
  2026-03-07 12:51             ` Jonathan Cameron
  0 siblings, 1 reply; 12+ messages in thread
From: Andy Shevchenko @ 2026-03-06 12:09 UTC (permalink / raw)
  To: David Lechner
  Cc: Andy Shevchenko, Francesco Lavra, Jonathan Cameron, Nuno Sá,
	Andy Shevchenko, Jonathan Corbet, Shuah Khan, linux-iio,
	linux-kernel, linux-doc

On Thu, Mar 05, 2026 at 08:37:48AM -0600, David Lechner wrote:
> On 3/5/26 3:23 AM, Andy Shevchenko wrote:
> > On Thu, Mar 5, 2026 at 11:09 AM Francesco Lavra <flavra@baylibre.com> wrote:
> >> On Wed, 2026-03-04 at 16:45 -0600, David Lechner wrote:
> >>> On 3/4/26 2:06 AM, Francesco Lavra wrote:
> >>>> In the data storage description of a scan element, the first character
> >>>> after the colon can have the values 's' and 'u' to specify signed and
> >>>> unsigned integers, respectively.
> >>>> Add 'f' as an allowed value to specify floating-point numbers formatted
> >>>> according to the IEEE 754 standard.

...

> >>>> -  Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift] .
> >>>> +  Format is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift] .
> >>>>
> >>>>    * *be* or *le*, specifies big or little endian.
> >>>> +  * *f*, specifies if floating-point.
> >>>>    * *s* or *u*, specifies if signed (2's complement) or unsigned.
> >>>
> >>> I would keep all of the format options on one bullet point.
> >>
> >> That's what I did initially, but Andy suggested doing differently [1].
> > 
> > And still I think it's better to not mix them. The floating in the
> > same sentence is confusing (along with 2's complement mention and
> > sign).
> 
> Then I would split up all 3. It is strange to mix some and not
> all.

I don't find it 'strange'. The integer are grouped together, floats do not
belong to that group.

...

> >>>> -is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where:
> >>>> +is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where:
> >>>>
> >>>>  - **be** or **le** specifies big or little-endian.
> >>>> +- **f** specifies if floating-point.
> >>>>  - **s** or **u** specifies if signed (2's complement) or unsigned.
> >>>
> >>> same here
> >>
> >> [1] https://lore.kernel.org/linux-iio/aZ7dCdLs5xcJ4UGW@smile.fi.intel.com/
> > 
> > Same here.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 2/6] iio: Replace 'sign' field with union in struct iio_scan_type
  2026-03-04 22:55   ` David Lechner
@ 2026-03-07 12:47     ` Jonathan Cameron
  0 siblings, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2026-03-07 12:47 UTC (permalink / raw)
  To: David Lechner
  Cc: Francesco Lavra, Jonathan Corbet, Shuah Khan, Nuno Sá,
	Andy Shevchenko, linux-doc, linux-kernel, linux-iio

On Wed, 4 Mar 2026 16:55:42 -0600
David Lechner <dlechner@baylibre.com> wrote:

> On 3/4/26 2:06 AM, Francesco Lavra wrote:
> > This field is used to differentiate between signed and unsigned integers.
> > A following commit will extend its use in order to add support for non-
> > integer scan elements; therefore, replace it with a union that contains a
> > more generic 'format' field. This union will be dropped when all drivers
> > are changed to use the format field.
> > 
> > Signed-off-by: Francesco Lavra <flavra@baylibre.com>
> > ---
> >  Documentation/driver-api/iio/buffers.rst | 4 ++--
> >  include/linux/iio/iio.h                  | 7 +++++--
> >  2 files changed, 7 insertions(+), 4 deletions(-)
> > 
> > diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst
> > index 63f364e862d1..f36e6d00173f 100644
> > --- a/Documentation/driver-api/iio/buffers.rst
> > +++ b/Documentation/driver-api/iio/buffers.rst
> > @@ -78,7 +78,7 @@ fields in iio_chan_spec definition::
> >     /* other members */
> >             int scan_index
> >             struct {
> > -                   char sign;
> > +                   char format;
> >                     u8 realbits;
> >                     u8 storagebits;
> >                     u8 shift;
> > @@ -98,7 +98,7 @@ following channel definition::
> >  		   /* other stuff here */
> >  		   .scan_index = 0,
> >  		   .scan_type = {
> > -		           .sign = 's',
> > +		           .format = 's',
> >  			   .realbits = 12,
> >  			   .storagebits = 16,
> >  			   .shift = 4,
> > diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h
> > index a9ecff191bd9..61f1dfc14e02 100644
> > --- a/include/linux/iio/iio.h
> > +++ b/include/linux/iio/iio.h
> > @@ -178,7 +178,7 @@ struct iio_event_spec {
> >  
> >  /**
> >   * struct iio_scan_type - specification for channel data format in buffer
> > - * @sign:		's' or 'u' to specify signed or unsigned

I think this is going to trigger kernel-doc warnings.  So I'd keep the docs
but mention it's deprecated in favour of format.

> > + * @format:		(signed or unsigned) integer, or floating point  
> 
> We should keep the list of valid values here.
> 
> >   * @realbits:		Number of valid bits of data
> >   * @storagebits:	Realbits + padding
> >   * @shift:		Shift right by this before masking out realbits.
> > @@ -189,7 +189,10 @@ struct iio_event_spec {
> >   * @endianness:		little or big endian
> >   */
> >  struct iio_scan_type {
> > -	char	sign;
> > +	union {
> > +		char sign;
> > +		char format;  
> 
> Could add some comments here to say that format should be used
> in new code and sign will be removed eventually.
> 
> > +	};
> >  	u8	realbits;
> >  	u8	storagebits;
> >  	u8	shift;  
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements
  2026-03-06 12:09           ` Andy Shevchenko
@ 2026-03-07 12:51             ` Jonathan Cameron
  2026-03-17 10:40               ` Francesco Lavra
  0 siblings, 1 reply; 12+ messages in thread
From: Jonathan Cameron @ 2026-03-07 12:51 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: David Lechner, Andy Shevchenko, Francesco Lavra, Nuno Sá,
	Andy Shevchenko, Jonathan Corbet, Shuah Khan, linux-iio,
	linux-kernel, linux-doc

On Fri, 6 Mar 2026 14:09:51 +0200
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Thu, Mar 05, 2026 at 08:37:48AM -0600, David Lechner wrote:
> > On 3/5/26 3:23 AM, Andy Shevchenko wrote:  
> > > On Thu, Mar 5, 2026 at 11:09 AM Francesco Lavra <flavra@baylibre.com> wrote:  
> > >> On Wed, 2026-03-04 at 16:45 -0600, David Lechner wrote:  
> > >>> On 3/4/26 2:06 AM, Francesco Lavra wrote:  
> > >>>> In the data storage description of a scan element, the first character
> > >>>> after the colon can have the values 's' and 'u' to specify signed and
> > >>>> unsigned integers, respectively.
> > >>>> Add 'f' as an allowed value to specify floating-point numbers formatted
> > >>>> according to the IEEE 754 standard.  
> 
> ...
> 
> > >>>> -  Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift] .
> > >>>> +  Format is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift] .
> > >>>>
> > >>>>    * *be* or *le*, specifies big or little endian.
> > >>>> +  * *f*, specifies if floating-point.
> > >>>>    * *s* or *u*, specifies if signed (2's complement) or unsigned.  
> > >>>
> > >>> I would keep all of the format options on one bullet point.  
> > >>
> > >> That's what I did initially, but Andy suggested doing differently [1].  
> > > 
> > > And still I think it's better to not mix them. The floating in the
> > > same sentence is confusing (along with 2's complement mention and
> > > sign).  
> > 
> > Then I would split up all 3. It is strange to mix some and not
> > all.  
> 
> I don't find it 'strange'. The integer are grouped together, floats do not
> belong to that group.
Maybe two paragaraphs in one bullet point?
	* *f*, specifies if floating-point.
	  *s* or *u*, specifies if signed (2's complement) or unsigned.  

Though then we'll definitely need to check it didn't break the formatting
in the docs generated from these files.

For me any of the above are fine.

	
> 
> ...
> 
> > >>>> -is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where:
> > >>>> +is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where:
> > >>>>
> > >>>>  - **be** or **le** specifies big or little-endian.
> > >>>> +- **f** specifies if floating-point.
> > >>>>  - **s** or **u** specifies if signed (2's complement) or unsigned.  
> > >>>
> > >>> same here  
> > >>
> > >> [1] https://lore.kernel.org/linux-iio/aZ7dCdLs5xcJ4UGW@smile.fi.intel.com/  
> > > 
> > > Same here.  
> 


^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 2/6] iio: Replace 'sign' field with union in struct iio_scan_type
  2026-03-04  8:06 ` [PATCH v7 2/6] iio: Replace 'sign' field with union in struct iio_scan_type Francesco Lavra
  2026-03-04 22:55   ` David Lechner
@ 2026-03-07 13:10   ` Jonathan Cameron
  1 sibling, 0 replies; 12+ messages in thread
From: Jonathan Cameron @ 2026-03-07 13:10 UTC (permalink / raw)
  To: Francesco Lavra
  Cc: Jonathan Corbet, Shuah Khan, David Lechner, Nuno Sá,
	Andy Shevchenko, linux-doc, linux-kernel, linux-iio

On Wed,  4 Mar 2026 09:06:40 +0100
Francesco Lavra <flavra@baylibre.com> wrote:

> This field is used to differentiate between signed and unsigned integers.
> A following commit will extend its use in order to add support for non-
> integer scan elements; therefore, replace it with a union that contains a
> more generic 'format' field. This union will be dropped when all drivers
> are changed to use the format field.
> 
> Signed-off-by: Francesco Lavra <flavra@baylibre.com>
> ---
>  Documentation/driver-api/iio/buffers.rst | 4 ++--
>  include/linux/iio/iio.h                  | 7 +++++--
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst
> index 63f364e862d1..f36e6d00173f 100644
> --- a/Documentation/driver-api/iio/buffers.rst
> +++ b/Documentation/driver-api/iio/buffers.rst
> @@ -78,7 +78,7 @@ fields in iio_chan_spec definition::
>     /* other members */
>             int scan_index
>             struct {
> -                   char sign;
> +                   char format;
>                     u8 realbits;
>                     u8 storagebits;
>                     u8 shift;
> @@ -98,7 +98,7 @@ following channel definition::
>  		   /* other stuff here */
>  		   .scan_index = 0,
>  		   .scan_type = {
> -		           .sign = 's',
> +		           .format = 's',
This made me wonder if we should use this opportunity to restrict
the flexibility of what can go in .format via some defines?

#define IIO_SCAN_FORMAT_SIGNED_INT 's'
#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u'
#define IIO_SCAN_FORMAT_FLOAT 'f'

or something like that.  Given the aim is to convert all current
instances we can move to the macros as part of switching from
sign to format.


>  			   .realbits = 12,
>  			   .storagebits = 16,
>  			   .shift = 4,

^ permalink raw reply	[flat|nested] 12+ messages in thread

* Re: [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements
  2026-03-07 12:51             ` Jonathan Cameron
@ 2026-03-17 10:40               ` Francesco Lavra
  0 siblings, 0 replies; 12+ messages in thread
From: Francesco Lavra @ 2026-03-17 10:40 UTC (permalink / raw)
  To: Jonathan Cameron, Andy Shevchenko
  Cc: David Lechner, Andy Shevchenko, Nuno Sá, Andy Shevchenko,
	Jonathan Corbet, Shuah Khan, linux-iio, linux-kernel, linux-doc

On Sat, 2026-03-07 at 12:51 +0000, Jonathan Cameron wrote:
> On Fri, 6 Mar 2026 14:09:51 +0200
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> 
> > On Thu, Mar 05, 2026 at 08:37:48AM -0600, David Lechner wrote:
> > > On 3/5/26 3:23 AM, Andy Shevchenko wrote:  
> > > > On Thu, Mar 5, 2026 at 11:09 AM Francesco Lavra
> > > > <flavra@baylibre.com> wrote:  
> > > > > On Wed, 2026-03-04 at 16:45 -0600, David Lechner wrote:  
> > > > > > On 3/4/26 2:06 AM, Francesco Lavra wrote:  
> > > > > > > In the data storage description of a scan element, the first
> > > > > > > character
> > > > > > > after the colon can have the values 's' and 'u' to specify
> > > > > > > signed and
> > > > > > > unsigned integers, respectively.
> > > > > > > Add 'f' as an allowed value to specify floating-point numbers
> > > > > > > formatted
> > > > > > > according to the IEEE 754 standard.  
> > 
> > ...
> > 
> > > > > > > -  Format is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift]
> > > > > > > .
> > > > > > > +  Format is
> > > > > > > [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift] .
> > > > > > > 
> > > > > > >    * *be* or *le*, specifies big or little endian.
> > > > > > > +  * *f*, specifies if floating-point.
> > > > > > >    * *s* or *u*, specifies if signed (2's complement) or
> > > > > > > unsigned.  
> > > > > > 
> > > > > > I would keep all of the format options on one bullet point.  
> > > > > 
> > > > > That's what I did initially, but Andy suggested doing differently
> > > > > [1].  
> > > > 
> > > > And still I think it's better to not mix them. The floating in the
> > > > same sentence is confusing (along with 2's complement mention and
> > > > sign).  
> > > 
> > > Then I would split up all 3. It is strange to mix some and not
> > > all.  
> > 
> > I don't find it 'strange'. The integer are grouped together, floats do
> > not
> > belong to that group.
> Maybe two paragaraphs in one bullet point?
>         * *f*, specifies if floating-point.
>           *s* or *u*, specifies if signed (2's complement) or unsigned.  
> 
> Though then we'll definitely need to check it didn't break the formatting
> in the docs generated from these files.

This does break the formatting in the HTML docs, where the two paragraphs
end up in the same line.

> For me any of the above are fine.

I will keep it as is.

> > ...
> > 
> > > > > > > -is [be|le]:[s|u]bits/storagebits[Xrepeat][>>shift], where:
> > > > > > > +is [be|le]:[f|s|u]bits/storagebits[Xrepeat][>>shift], where:
> > > > > > > 
> > > > > > >  - **be** or **le** specifies big or little-endian.
> > > > > > > +- **f** specifies if floating-point.
> > > > > > >  - **s** or **u** specifies if signed (2's complement) or
> > > > > > > unsigned.  
> > > > > > 
> > > > > > same here  
> > > > > 
> > > > > [1]
> > > > > https://lore.kernel.org/linux-iio/aZ7dCdLs5xcJ4UGW@smile.fi.intel.com/
> > > > >  
> > > > 
> > > > Same here.

Same here.

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-17 10:40 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20260304080519.2844101-1-flavra@baylibre.com>
2026-03-04  8:06 ` [PATCH v7 2/6] iio: Replace 'sign' field with union in struct iio_scan_type Francesco Lavra
2026-03-04 22:55   ` David Lechner
2026-03-07 12:47     ` Jonathan Cameron
2026-03-07 13:10   ` Jonathan Cameron
2026-03-04  8:06 ` [PATCH v7 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements Francesco Lavra
2026-03-04 22:45   ` David Lechner
2026-03-05  9:09     ` Francesco Lavra
2026-03-05  9:23       ` Andy Shevchenko
2026-03-05 14:37         ` David Lechner
2026-03-06 12:09           ` Andy Shevchenko
2026-03-07 12:51             ` Jonathan Cameron
2026-03-17 10:40               ` Francesco Lavra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox