Re: [PATCH v5 13/16] iio: adc: xilinx-xadc: Add helper functions for the device setup
From: Andy Shevchenko
Date: Tue Nov 10 2026 - 11:46:22 EST
On Tue, Nov 10, 2026 at 10:31:58AM +0530, Dileep Kumar Nagavarapu wrote:
> Refactor the platform driver probe function by extracting device
> setup and configuration logic into reusable helper functions:
> xadc_device_setup(): handles IIO device allocation and basic setup
> xadc_device_configure(): handles device tree parsing and bipolar mask
> configuration
>
> Move the bipolar channel mask calculation immediately after
> xadc_parse_dt(), as the channel information used to build
> the mask is populated there and remains unchanged before it is consumed.
>
> This refactoring reduces code duplication and prepares for sharing the
> common setup logic between platform and I2C drivers.
...
> + if (irq <= 0)
> + return 0;
When == 0 is true?
...
> +static int xadc_device_configure(struct iio_dev *indio_dev, int irq,
> + unsigned int *conf0, unsigned int *bipolar_mask)
> +{
> + int ret;
> +
> + ret = xadc_parse_dt(indio_dev, conf0, irq);
> + if (ret)
> + return ret;
> +
> + *bipolar_mask = 0;
> + for (unsigned int i = 0; i < indio_dev->num_channels; i++) {
> + if (indio_dev->channels[i].scan_type.sign == 's')
Wasn't that changed to format?
> + *bipolar_mask |= BIT(indio_dev->channels[i].scan_index);
> + }
> +
> + return 0;
Don't we have a specific for_each type of macro to iterate over all channels?
> +}
...
> irq = platform_get_irq_optional(pdev, 0);
> if (irq < 0 && (irq != -ENXIO || !(ops->flags & XADC_FLAGS_IRQ_OPTIONAL)))
Side note, this conditional is wrong. It doesn't handle properly deferred probe.
> return irq;
--
With Best Regards,
Andy Shevchenko