* [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type [not found] <20260317150316.3878107-1-flavra@baylibre.com> @ 2026-03-17 15:04 ` Francesco Lavra 2026-03-21 17:22 ` David Lechner 2026-03-17 15:04 ` [PATCH v8 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements Francesco Lavra 1 sibling, 1 reply; 10+ messages in thread From: Francesco Lavra @ 2026-03-17 15:04 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. Opportunistically replace character literals with symbolic constants that represent the set of allowed values for the format field. Signed-off-by: Francesco Lavra <flavra@baylibre.com> --- Documentation/driver-api/iio/buffers.rst | 4 ++-- include/linux/iio/iio.h | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst index 63f364e862d1..e16abaf826fe 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 = IIO_SCAN_FORMAT_SIGNED_INT, .realbits = 12, .storagebits = 16, .shift = 4, diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index a9ecff191bd9..d48a0ab01b8d 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -176,9 +176,19 @@ struct iio_event_spec { unsigned long mask_shared_by_all; }; +/* + * Format values in scan type + * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's complement). + * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. + */ +#define IIO_SCAN_FORMAT_SIGNED_INT 's' +#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' + /** * struct iio_scan_type - specification for channel data format in buffer - * @sign: 's' or 'u' to specify signed or unsigned + * @sign: Deprecated, use @format instead. + * @format: Data format, can have any of the IIO_SCAN_FORMAT_* + * values. * @realbits: Number of valid bits of data * @storagebits: Realbits + padding * @shift: Shift right by this before masking out realbits. @@ -189,7 +199,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] 10+ messages in thread
* Re: [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type 2026-03-17 15:04 ` [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type Francesco Lavra @ 2026-03-21 17:22 ` David Lechner 2026-03-23 16:04 ` Francesco Lavra 0 siblings, 1 reply; 10+ messages in thread From: David Lechner @ 2026-03-21 17:22 UTC (permalink / raw) To: Francesco Lavra, Jonathan Corbet, Shuah Khan, Jonathan Cameron, Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio On 3/17/26 10:04 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. > Opportunistically replace character literals with symbolic constants that > represent the set of allowed values for the format field. > > Signed-off-by: Francesco Lavra <flavra@baylibre.com> > --- > Documentation/driver-api/iio/buffers.rst | 4 ++-- > include/linux/iio/iio.h | 17 +++++++++++++++-- > 2 files changed, 17 insertions(+), 4 deletions(-) > > diff --git a/Documentation/driver-api/iio/buffers.rst b/Documentation/driver-api/iio/buffers.rst > index 63f364e862d1..e16abaf826fe 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 = IIO_SCAN_FORMAT_SIGNED_INT, > .realbits = 12, > .storagebits = 16, > .shift = 4, > diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h > index a9ecff191bd9..d48a0ab01b8d 100644 > --- a/include/linux/iio/iio.h > +++ b/include/linux/iio/iio.h > @@ -176,9 +176,19 @@ struct iio_event_spec { > unsigned long mask_shared_by_all; > }; > > +/* > + * Format values in scan type > + * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's complement). > + * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. > + */ We could make this proper kernel doc format with one comment per macro. > +#define IIO_SCAN_FORMAT_SIGNED_INT 's' > +#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' > + > /** > * struct iio_scan_type - specification for channel data format in buffer > - * @sign: 's' or 'u' to specify signed or unsigned > + * @sign: Deprecated, use @format instead. > + * @format: Data format, can have any of the IIO_SCAN_FORMAT_* > + * values. > * @realbits: Number of valid bits of data > * @storagebits: Realbits + padding > * @shift: Shift right by this before masking out realbits. > @@ -189,7 +199,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; ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type 2026-03-21 17:22 ` David Lechner @ 2026-03-23 16:04 ` Francesco Lavra 2026-03-23 16:08 ` David Lechner 2026-03-23 16:49 ` Andy Shevchenko 0 siblings, 2 replies; 10+ messages in thread From: Francesco Lavra @ 2026-03-23 16:04 UTC (permalink / raw) To: David Lechner, Jonathan Corbet, Shuah Khan, Jonathan Cameron, Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio On Sat, 2026-03-21 at 12:22 -0500, David Lechner wrote: > On 3/17/26 10:04 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. > > Opportunistically replace character literals with symbolic constants > > that > > represent the set of allowed values for the format field. > > > > Signed-off-by: Francesco Lavra <flavra@baylibre.com> > > --- > > Documentation/driver-api/iio/buffers.rst | 4 ++-- > > include/linux/iio/iio.h | 17 +++++++++++++++-- > > 2 files changed, 17 insertions(+), 4 deletions(-) > > > > diff --git a/Documentation/driver-api/iio/buffers.rst > > b/Documentation/driver-api/iio/buffers.rst > > index 63f364e862d1..e16abaf826fe 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 = IIO_SCAN_FORMAT_SIGNED_INT, > > .realbits = 12, > > .storagebits = 16, > > .shift = 4, > > diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h > > index a9ecff191bd9..d48a0ab01b8d 100644 > > --- a/include/linux/iio/iio.h > > +++ b/include/linux/iio/iio.h > > @@ -176,9 +176,19 @@ struct iio_event_spec { > > unsigned long mask_shared_by_all; > > }; > > > > +/* > > + * Format values in scan type > > + * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's complement). > > + * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. > > + */ > > We could make this proper kernel doc format with one comment per macro. Actually, a set of related #defines can be documented with a single comment. I see a few examples doing that in include/linux/gfp_types.h and include/linux/fpga/fpga-mgr.h > > +#define IIO_SCAN_FORMAT_SIGNED_INT 's' > > +#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' > > + ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type 2026-03-23 16:04 ` Francesco Lavra @ 2026-03-23 16:08 ` David Lechner 2026-03-23 16:49 ` Andy Shevchenko 1 sibling, 0 replies; 10+ messages in thread From: David Lechner @ 2026-03-23 16:08 UTC (permalink / raw) To: Francesco Lavra, Jonathan Corbet, Shuah Khan, Jonathan Cameron, Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio On 3/23/26 11:04 AM, Francesco Lavra wrote: > On Sat, 2026-03-21 at 12:22 -0500, David Lechner wrote: >> On 3/17/26 10:04 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. >>> Opportunistically replace character literals with symbolic constants >>> that >>> represent the set of allowed values for the format field. >>> >>> Signed-off-by: Francesco Lavra <flavra@baylibre.com> >>> --- >>> Documentation/driver-api/iio/buffers.rst | 4 ++-- >>> include/linux/iio/iio.h | 17 +++++++++++++++-- >>> 2 files changed, 17 insertions(+), 4 deletions(-) >>> >>> diff --git a/Documentation/driver-api/iio/buffers.rst >>> b/Documentation/driver-api/iio/buffers.rst >>> index 63f364e862d1..e16abaf826fe 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 = IIO_SCAN_FORMAT_SIGNED_INT, >>> .realbits = 12, >>> .storagebits = 16, >>> .shift = 4, >>> diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h >>> index a9ecff191bd9..d48a0ab01b8d 100644 >>> --- a/include/linux/iio/iio.h >>> +++ b/include/linux/iio/iio.h >>> @@ -176,9 +176,19 @@ struct iio_event_spec { >>> unsigned long mask_shared_by_all; >>> }; >>> >>> +/* >>> + * Format values in scan type >>> + * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's complement). >>> + * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. >>> + */ >> >> We could make this proper kernel doc format with one comment per macro. > > Actually, a set of related #defines can be documented with a single > comment. I see a few examples doing that in include/linux/gfp_types.h and > include/linux/fpga/fpga-mgr.h Fancy. Although, IDEs tend to be able to handle doc comments better if they are not combined (i.e. getting the docs when you hold the mouse over an identifier). > > >>> +#define IIO_SCAN_FORMAT_SIGNED_INT 's' >>> +#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' >>> + > ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type 2026-03-23 16:04 ` Francesco Lavra 2026-03-23 16:08 ` David Lechner @ 2026-03-23 16:49 ` Andy Shevchenko 2026-03-23 17:37 ` Francesco Lavra 1 sibling, 1 reply; 10+ messages in thread From: Andy Shevchenko @ 2026-03-23 16:49 UTC (permalink / raw) To: Francesco Lavra Cc: David Lechner, Jonathan Corbet, Shuah Khan, Jonathan Cameron, Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio On Mon, Mar 23, 2026 at 05:04:10PM +0100, Francesco Lavra wrote: > On Sat, 2026-03-21 at 12:22 -0500, David Lechner wrote: > > On 3/17/26 10:04 AM, Francesco Lavra wrote: ... > > > + * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's complement). > > > + * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. > > We could make this proper kernel doc format with one comment per macro. > > Actually, a set of related #defines can be documented with a single > comment. I see a few examples doing that in include/linux/gfp_types.h and > include/linux/fpga/fpga-mgr.h > > > > +#define IIO_SCAN_FORMAT_SIGNED_INT 's' > > > +#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' ...or use enum /** * ...kernel-doc for enum... */ enum { IIO_SCAN_FORMAT_SIGNED_INT = 's', IIO_SCAN_FORMAT_UNSIGNED_INT = 'u', }; -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type 2026-03-23 16:49 ` Andy Shevchenko @ 2026-03-23 17:37 ` Francesco Lavra 2026-03-24 11:04 ` Andy Shevchenko 0 siblings, 1 reply; 10+ messages in thread From: Francesco Lavra @ 2026-03-23 17:37 UTC (permalink / raw) To: Andy Shevchenko Cc: David Lechner, Jonathan Corbet, Shuah Khan, Jonathan Cameron, Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio On Mon, 2026-03-23 at 18:49 +0200, Andy Shevchenko wrote: > On Mon, Mar 23, 2026 at 05:04:10PM +0100, Francesco Lavra wrote: > > On Sat, 2026-03-21 at 12:22 -0500, David Lechner wrote: > > > On 3/17/26 10:04 AM, Francesco Lavra wrote: > > ... > > > > > + * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's complement). > > > > + * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. > > > > We could make this proper kernel doc format with one comment per > > > macro. > > > > Actually, a set of related #defines can be documented with a single > > comment. I see a few examples doing that in include/linux/gfp_types.h > > and > > include/linux/fpga/fpga-mgr.h > > > > > > +#define IIO_SCAN_FORMAT_SIGNED_INT 's' > > > > +#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' > > ...or use enum > > /** > * ...kernel-doc for enum... > */ > enum { > IIO_SCAN_FORMAT_SIGNED_INT = 's', > IIO_SCAN_FORMAT_UNSIGNED_INT = 'u', > }; There is no standard kernel-doc format for anonymous enums. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type 2026-03-23 17:37 ` Francesco Lavra @ 2026-03-24 11:04 ` Andy Shevchenko 2026-03-24 11:42 ` Francesco Lavra 0 siblings, 1 reply; 10+ messages in thread From: Andy Shevchenko @ 2026-03-24 11:04 UTC (permalink / raw) To: Francesco Lavra Cc: David Lechner, Jonathan Corbet, Shuah Khan, Jonathan Cameron, Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio On Mon, Mar 23, 2026 at 06:37:38PM +0100, Francesco Lavra wrote: > On Mon, 2026-03-23 at 18:49 +0200, Andy Shevchenko wrote: > > On Mon, Mar 23, 2026 at 05:04:10PM +0100, Francesco Lavra wrote: > > > On Sat, 2026-03-21 at 12:22 -0500, David Lechner wrote: > > > > On 3/17/26 10:04 AM, Francesco Lavra wrote: ... > > > > > + * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's complement). > > > > > + * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. > > > > > > We could make this proper kernel doc format with one comment per > > > > macro. > > > > > > Actually, a set of related #defines can be documented with a single > > > comment. I see a few examples doing that in include/linux/gfp_types.h > > > and > > > include/linux/fpga/fpga-mgr.h > > > > > > > > +#define IIO_SCAN_FORMAT_SIGNED_INT 's' > > > > > +#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' > > > > ...or use enum > > > > /** > > * ...kernel-doc for enum... > > */ > > enum { > > IIO_SCAN_FORMAT_SIGNED_INT = 's', > > IIO_SCAN_FORMAT_UNSIGNED_INT = 'u', > > }; > > There is no standard kernel-doc format for anonymous enums. What do you mean? We have such in kernel, for example, drivers/pinctrl/intel/pinctrl-intel.c. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type 2026-03-24 11:04 ` Andy Shevchenko @ 2026-03-24 11:42 ` Francesco Lavra 2026-03-24 11:52 ` Andy Shevchenko 0 siblings, 1 reply; 10+ messages in thread From: Francesco Lavra @ 2026-03-24 11:42 UTC (permalink / raw) To: Andy Shevchenko Cc: David Lechner, Jonathan Corbet, Shuah Khan, Jonathan Cameron, Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio On Tue, 2026-03-24 at 13:04 +0200, Andy Shevchenko wrote: > On Mon, Mar 23, 2026 at 06:37:38PM +0100, Francesco Lavra wrote: > > On Mon, 2026-03-23 at 18:49 +0200, Andy Shevchenko wrote: > > > On Mon, Mar 23, 2026 at 05:04:10PM +0100, Francesco Lavra wrote: > > > > On Sat, 2026-03-21 at 12:22 -0500, David Lechner wrote: > > > > > On 3/17/26 10:04 AM, Francesco Lavra wrote: > > ... > > > > > > > + * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's > > > > > > complement). > > > > > > + * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. > > > > > > > > We could make this proper kernel doc format with one comment per > > > > > macro. > > > > > > > > Actually, a set of related #defines can be documented with a single > > > > comment. I see a few examples doing that in > > > > include/linux/gfp_types.h > > > > and > > > > include/linux/fpga/fpga-mgr.h > > > > > > > > > > +#define IIO_SCAN_FORMAT_SIGNED_INT 's' > > > > > > +#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' > > > > > > ...or use enum > > > > > > /** > > > * ...kernel-doc for enum... > > > */ > > > enum { > > > IIO_SCAN_FORMAT_SIGNED_INT = 's', > > > IIO_SCAN_FORMAT_UNSIGNED_INT = 'u', > > > }; > > > > There is no standard kernel-doc format for anonymous enums. > > What do you mean? We have such in kernel, for example, > drivers/pinctrl/intel/pinctrl-intel.c. The kernel-doc guidelines at Documentation/doc-guide/kernel-doc.rst, in the section that describe structure, union, and enumeration documentation, include the name of the struct in the example, so I thought they wouldn't apply to anonymous types. But now I see that anonymous enum comments are processed just fine by the kernel-doc tool. Anyway, in v9 I switched to one comment per macro, as suggested by David. ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type 2026-03-24 11:42 ` Francesco Lavra @ 2026-03-24 11:52 ` Andy Shevchenko 0 siblings, 0 replies; 10+ messages in thread From: Andy Shevchenko @ 2026-03-24 11:52 UTC (permalink / raw) To: Francesco Lavra Cc: David Lechner, Jonathan Corbet, Shuah Khan, Jonathan Cameron, Nuno Sá, Andy Shevchenko, linux-doc, linux-kernel, linux-iio On Tue, Mar 24, 2026 at 12:42:19PM +0100, Francesco Lavra wrote: > On Tue, 2026-03-24 at 13:04 +0200, Andy Shevchenko wrote: > > On Mon, Mar 23, 2026 at 06:37:38PM +0100, Francesco Lavra wrote: > > > On Mon, 2026-03-23 at 18:49 +0200, Andy Shevchenko wrote: > > > > On Mon, Mar 23, 2026 at 05:04:10PM +0100, Francesco Lavra wrote: > > > > > On Sat, 2026-03-21 at 12:22 -0500, David Lechner wrote: > > > > > > On 3/17/26 10:04 AM, Francesco Lavra wrote: ... > > > > > > > + * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's > > > > > > > complement). > > > > > > > + * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. > > > > > > > > > > We could make this proper kernel doc format with one comment per > > > > > > macro. > > > > > > > > > > Actually, a set of related #defines can be documented with a single > > > > > comment. I see a few examples doing that in > > > > > include/linux/gfp_types.h > > > > > and > > > > > include/linux/fpga/fpga-mgr.h > > > > > > > > > > > > +#define IIO_SCAN_FORMAT_SIGNED_INT 's' > > > > > > > +#define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' > > > > > > > > ...or use enum > > > > > > > > /** > > > > * ...kernel-doc for enum... > > > > */ > > > > enum { > > > > IIO_SCAN_FORMAT_SIGNED_INT = 's', > > > > IIO_SCAN_FORMAT_UNSIGNED_INT = 'u', > > > > }; > > > > > > There is no standard kernel-doc format for anonymous enums. > > > > What do you mean? We have such in kernel, for example, > > drivers/pinctrl/intel/pinctrl-intel.c. > > The kernel-doc guidelines at Documentation/doc-guide/kernel-doc.rst, in the > section that describe structure, union, and enumeration documentation, > include the name of the struct in the example, so I thought they wouldn't > apply to anonymous types. But now I see that anonymous enum comments are > processed just fine by the kernel-doc tool. > Anyway, in v9 I switched to one comment per macro, as suggested by David. WFM, thanks. -- With Best Regards, Andy Shevchenko ^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v8 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements [not found] <20260317150316.3878107-1-flavra@baylibre.com> 2026-03-17 15:04 ` [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type Francesco Lavra @ 2026-03-17 15:04 ` Francesco Lavra 1 sibling, 0 replies; 10+ messages in thread From: Francesco Lavra @ 2026-03-17 15:04 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 ++- include/linux/iio/iio.h | 2 ++ 4 files changed, 24 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 e16abaf826fe..8779022e3da5 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 diff --git a/include/linux/iio/iio.h b/include/linux/iio/iio.h index d48a0ab01b8d..1f2c1cb03394 100644 --- a/include/linux/iio/iio.h +++ b/include/linux/iio/iio.h @@ -180,9 +180,11 @@ struct iio_event_spec { * Format values in scan type * @IIO_SCAN_FORMAT_SIGNED_INT: Signed integer (two's complement). * @IIO_SCAN_FORMAT_UNSIGNED_INT: Unsigned integer. + * @IIO_SCAN_FORMAT_FLOAT: Floating point. */ #define IIO_SCAN_FORMAT_SIGNED_INT 's' #define IIO_SCAN_FORMAT_UNSIGNED_INT 'u' +#define IIO_SCAN_FORMAT_FLOAT 'f' /** * struct iio_scan_type - specification for channel data format in buffer -- 2.39.5 ^ permalink raw reply related [flat|nested] 10+ messages in thread
end of thread, other threads:[~2026-03-24 11:52 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260317150316.3878107-1-flavra@baylibre.com>
2026-03-17 15:04 ` [PATCH v8 2/6] iio: Replace 'sign' field with union in struct iio_scan_type Francesco Lavra
2026-03-21 17:22 ` David Lechner
2026-03-23 16:04 ` Francesco Lavra
2026-03-23 16:08 ` David Lechner
2026-03-23 16:49 ` Andy Shevchenko
2026-03-23 17:37 ` Francesco Lavra
2026-03-24 11:04 ` Andy Shevchenko
2026-03-24 11:42 ` Francesco Lavra
2026-03-24 11:52 ` Andy Shevchenko
2026-03-17 15:04 ` [PATCH v8 4/6] iio: ABI: Add support for floating-point numbers in buffer scan elements Francesco Lavra
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox