[PATCH] iio: adc: sun20i-gpadc: support non-contiguous channel lookups
Andy Shevchenko
andriy.shevchenko at intel.com
Wed May 13 03:53:50 PDT 2026
On Wed, May 13, 2026 at 11:51:31AM +0200, Michal Piekos wrote:
> Using consumer driver like iio-hwmon which resolve channels thorugh
> io-channels phandles will fail for sparse channels because IIO core
> threats phandle argument as index into channel array.
> eg. <&gpadc 1> will fail if there is only channel at 1 specified
>
> Add fwnode_xlate which maps DT phandle to the registered channel whose
.fwnode_xlate()
> chan->channel matches the hardware channel number. It allows sparse
> channel maps to be consumed by drivers like iio-hwmon.
...
> +static int sun20i_gpadc_fwnode_xlate(struct iio_dev *indio_dev,
> + const struct fwnode_reference_args *iiospec)
Broken indentation (I understand the motivation to shift left, but I leave it
to Jonathan on how to proceed with this).
> +{
> + int i;
> +
> + for (i = 0; i < indio_dev->num_channels; i++)
for (unsigned int i = 0; i < indio_dev->num_channels; i++)
> + if (indio_dev->channels[i].channel == iiospec->args[0])
> + return i;
> +
> + return -EINVAL;
> +}
--
With Best Regards,
Andy Shevchenko
More information about the linux-arm-kernel
mailing list