[PATCH v5 13/16] iio: adc: xilinx-xadc: Add helper functions for the device setup
Nagavarapu, Dileep Kumar
dnagavar at amd.com
Tue Nov 17 00:07:40 PST 2026
Hi Andy,
On 11/10/2026 9:55 PM, Andy Shevchenko wrote:
> Caution: This message originated from an External Source. Use proper caution when opening attachments, clicking links, or responding.
>
>
> 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?
>
irq == 0 is not expected to be a valid successful return in this path.
I’ll update the code to use the suggested early-return structure
> ...
>
>> +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?
>
I'll switch to scan_type.format == IIO_SCAN_FORMAT_SIGNED_INT, is it ok?
>> + *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?
>
I couldn't find a for_each helper for iterating over all channels, so I
kept the plain loop
>> +}
>
> ...
>
>> 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
Thanks,
Dileep
More information about the linux-arm-kernel
mailing list