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

From: David Lechner
Date: Tue Aug 12 2025 - 10:32:05 EST


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@xxxxxxxxxx>
> Cc: Jonathan Cameron <jic23@xxxxxxxxxx>
> Cc: David Lechner <dlechner@xxxxxxxxxxxx>
> Cc: Nuno Sá <nuno.sa@xxxxxxxxxx>
> Cc: Andy Shevchenko <andy@xxxxxxxxxx>
>
> ---
> 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@xxxxxxxxxxxx>