[PATCH] iio: iio_format_list() should set stride=1 for IIO_VAL_CHAR

Ben Collins posted 1 patch 1 month, 3 weeks ago
drivers/iio/industrialio-core.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] iio: iio_format_list() should set stride=1 for IIO_VAL_CHAR
Posted by Ben Collins 1 month, 3 weeks ago
iio_format_list() sets a stride across the val array of 1 for INT
type, and 2 for all others. Add IIO_VAL_CHAR so it also gets a
stride of 1 assuming val is an array of integers with char type
values.

No drivers currently use this, but I found this issue adding an
avail callback for IIO_INFO_THERMOCOUPLE_TYPE for a driver I'm
working on.

Signed-off-by: Ben Collins <bcollins@kernel.org>
Cc: Jonathan Cameron <jic23@kernel.org>
Cc: David Lechner <dlechner@baylibre.com>
Cc: Nuno Sá <nuno.sa@analog.com>
Cc: Andy Shevchenko <andy@kernel.org>

---
 drivers/iio/industrialio-core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 159d6c5ca3cec..eb6a54f8115de 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -790,6 +790,7 @@ static ssize_t iio_format_list(char *buf, const int *vals, int type, int length,
 
 	switch (type) {
 	case IIO_VAL_INT:
+	case IIO_VAL_CHAR:
 		stride = 1;
 		break;
 	default:
-- 
2.50.1

-- 
 Ben Collins
 https://libjwt.io
 https://github.com/benmcollins
 --
 3EC9 7598 1672 961A 1139  173A 5D5A 57C7 242B 22CF
Re: [PATCH] iio: iio_format_list() should set stride=1 for IIO_VAL_CHAR
Posted by Andy Shevchenko 1 month, 3 weeks ago
On Tue, Aug 12, 2025 at 1:13 PM Ben Collins <bcollins@kernel.org> wrote:
>
> iio_format_list() sets a stride across the val array of 1 for INT
> type, and 2 for all others. Add IIO_VAL_CHAR so it also gets a
> stride of 1 assuming val is an array of integers with char type
> values.
>
> No drivers currently use this, but I found this issue adding an
> avail callback for IIO_INFO_THERMOCOUPLE_TYPE for a driver I'm
> working on.
>
> Signed-off-by: Ben Collins <bcollins@kernel.org>

Please, keep the Cc list after the '---' line (note, you may have more
than a single one in the patch, hence you may just add it here). This
will reduce the unneeded noise in the commit message as the very same
information will be available in the email headers and in lore
archive.

> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: David Lechner <dlechner@baylibre.com>
> Cc: Nuno Sá <nuno.sa@analog.com>
> Cc: Andy Shevchenko <andy@kernel.org>
>
> ---
>  drivers/iio/industrialio-core.c | 1 +
>  1 file changed, 1 insertion(+)


-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH] iio: iio_format_list() should set stride=1 for IIO_VAL_CHAR
Posted by Andy Shevchenko 1 month, 3 weeks ago
On Tue, Aug 12, 2025 at 10:44:13PM +0200, Andy Shevchenko wrote:
> On Tue, Aug 12, 2025 at 1:13 PM Ben Collins <bcollins@kernel.org> wrote:

...

> > Signed-off-by: Ben Collins <bcollins@kernel.org>
> 
> Please, keep the Cc list after the '---' line (note, you may have more
> than a single one in the patch, hence you may just add it here). This
> will reduce the unneeded noise in the commit message as the very same
> information will be available in the email headers and in lore
> archive.
> 
> > Cc: Jonathan Cameron <jic23@kernel.org>
> > Cc: David Lechner <dlechner@baylibre.com>
> > Cc: Nuno Sá <nuno.sa@analog.com>
> > Cc: Andy Shevchenko <andy@kernel.org>
> >
> > ---
> >  drivers/iio/industrialio-core.c | 1 +
> >  1 file changed, 1 insertion(+)

Forgot to add that no need to resend just for _this_ case, take the above
advice for the future contributions. I hope Jonathan may remove these Cc from
the commit message.

-- 
With Best Regards,
Andy Shevchenko


Re: [PATCH] iio: iio_format_list() should set stride=1 for IIO_VAL_CHAR
Posted by Jonathan Cameron 1 month, 2 weeks ago
On Wed, 13 Aug 2025 16:15:16 +0300
Andy Shevchenko <andriy.shevchenko@intel.com> wrote:

> On Tue, Aug 12, 2025 at 10:44:13PM +0200, Andy Shevchenko wrote:
> > On Tue, Aug 12, 2025 at 1:13 PM Ben Collins <bcollins@kernel.org> wrote:  
> 
> ...
> 
> > > Signed-off-by: Ben Collins <bcollins@kernel.org>  
> > 
> > Please, keep the Cc list after the '---' line (note, you may have more
> > than a single one in the patch, hence you may just add it here). This
> > will reduce the unneeded noise in the commit message as the very same
> > information will be available in the email headers and in lore
> > archive.
> >   
> > > Cc: Jonathan Cameron <jic23@kernel.org>
> > > Cc: David Lechner <dlechner@baylibre.com>
> > > Cc: Nuno Sá <nuno.sa@analog.com>
> > > Cc: Andy Shevchenko <andy@kernel.org>
> > >
> > > ---
> > >  drivers/iio/industrialio-core.c | 1 +
> > >  1 file changed, 1 insertion(+)  
> 
> Forgot to add that no need to resend just for _this_ case, take the above
> advice for the future contributions. I hope Jonathan may remove these Cc from
> the commit message.
> 

Tweaked that and applied.

Thanks,

Jonathan
Re: [PATCH] iio: iio_format_list() should set stride=1 for IIO_VAL_CHAR
Posted by David Lechner 1 month, 3 weeks ago
On 8/12/25 6:12 AM, Ben Collins wrote:
> iio_format_list() sets a stride across the val array of 1 for INT
> type, and 2 for all others. Add IIO_VAL_CHAR so it also gets a
> stride of 1 assuming val is an array of integers with char type
> values.
> 
> No drivers currently use this, but I found this issue adding an
> avail callback for IIO_INFO_THERMOCOUPLE_TYPE for a driver I'm
> working on.
> 
> Signed-off-by: Ben Collins <bcollins@kernel.org>
> Cc: Jonathan Cameron <jic23@kernel.org>
> Cc: David Lechner <dlechner@baylibre.com>
> Cc: Nuno Sá <nuno.sa@analog.com>
> Cc: Andy Shevchenko <andy@kernel.org>
> 
> ---
>  drivers/iio/industrialio-core.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
> index 159d6c5ca3cec..eb6a54f8115de 100644
> --- a/drivers/iio/industrialio-core.c
> +++ b/drivers/iio/industrialio-core.c
> @@ -790,6 +790,7 @@ static ssize_t iio_format_list(char *buf, const int *vals, int type, int length,
>  
>  	switch (type) {
>  	case IIO_VAL_INT:
> +	case IIO_VAL_CHAR:
>  		stride = 1;
>  		break;
>  	default:

Reviewed-by: David Lechner <dlechner@baylibre.com>