Re: [RFC PATCH v1 1/4] iio: adc: Add Allwinner D1/T113s/R329 SoCs GPADC

From: Maxim Kiselev
Date: Wed May 24 2023 - 08:15:19 EST


Andre Przywara <andre.przywara@xxxxxxx> wrote:
> Or we follow the other idea of reading the number of channels from a DT
> property, which means we would already support every IP with up to 16
> channels, without further driver changes in the future.

I like this idea. This will rid us from duplicating code, and we could also
use a common DT node for D1 and T113.

> Is there any particular reason you chose a regmap to model this here?
> Isn't that just straight-forward MMIO, which we could just drive using
> readl()/writel()?

Actually there is no special reason. I just made it in the same way as
in the sun4i-gpadc-iio driver.

> I wonder if this should be either moved out to some multiplexer: the DT
> bindings suggest that such a thing could be independent.

Sorry I didn't quite get it :)

> But at least we could cater for the possibility that this channel is
> already selected, and skip this part then?

Thanks for that suggestion.

> Couldn't taking the lock go into the function? It seems to be only one
> caller,

Yes, we could. Thanks for the remark.

> and we need the lock in any case, it seems?

This lock is used in others ADC drivers to protects a read access from
ocurring before another one has finished.


Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
> Even though regmap adds a few nice features that might be used.
> For example, locking. But I dunno if this driver actually uses it
> OR uses it correctly.

Just I wrote above, I made it in the same way as in the
sun4i-gpadc-iio driver

> > > + config = of_device_get_match_data(&pdev->dev);
>
> Please, avoid using OF-centric APIs in the new IIO drivers.
>
> config = device_get_match_data(&pdev->dev);
>
> should suffice.

> > + irq = platform_get_irq(pdev, 0);
> > + if (irq < 0)
> > + return dev_err_probe(&pdev->dev, irq, "failed to get irq\n");
>
> > > We should not repeat the message that printed by platform core.

> > > + ret = devm_request_irq(&pdev->dev, irq, sun20i_gpadc_irq_handler,
> > > + 0, dev_name(&pdev->dev), info);
>
> You can simplify your life with
>
> struct device *dev = &pdev->dev;
>
> at the definition block of the function.
> > > + .data = &sun20i_d1_gpadc_channels[1]
>
> Also, leave comma here.

Thanks for the remarks, I'll fix this in the next version.