Re: [PATCH] iio: adc: ad7173: fix compiling without gpiolib
From: Jonathan Cameron
Date: Sat Apr 26 2025 - 11:18:28 EST
On Wed, 23 Apr 2025 00:03:38 +0300
Andy Shevchenko <andy.shevchenko@xxxxxxxxx> wrote:
> On Tue, Apr 22, 2025 at 11:12 PM David Lechner <dlechner@xxxxxxxxxxxx> wrote:
> >
> > Fix compiling the ad7173 driver when CONFIG_GPIOLIB is not set by
> > selecting GPIOLIB to be always enabled and remove the #if.
>
> I'm not sure we need to select GPIOLIB. If you want it, depend on it.
> GPIOLIB is not a hidden symbol, so why "select"?
>
> > Commit 031bdc8aee01 ("iio: adc: ad7173: add calibration support") placed
> > unrelated code in the middle of the #if IS_ENABLED(CONFIG_GPIOLIB) block
> > which caused the reported compile error.
> >
> > However, later commit 7530ed2aaa3f ("iio: adc: ad7173: add openwire
> > detection support for single conversions") makes use of the gpio regmap
> > even when we aren't providing gpio controller support. So it makes more
> > sense to always enable GPIOLIB rather than trying to make it optional.
>
> ...
>
> > Not related to the fix, but I also question the use of the regmap here.
> > This is one of the ad_sigma_delta drivers that does funny things with
> > the SPI bus, like keeping it locked during the entire time a buffer is
> > enabled. So, if someone tried to use a GPIO during a buffered read, the
> > GPIO call could block (waiting for the SPI bus mutex) until the buffer
> > is disabled, which could be an indefinitely long time. And to make it
> > even worse, this is not an interruptible wait, so the GPIO consumer
> > would effectively be deadlocked.
>
> I would say either the entire buffer mode is broken (in software), or
> hardware is broken and GPIO shouldn't be supported at all if the
> buffer mode is enabled. I think the best solution here is to remove
> the GPIO chip before enabling buffered mode. If GPIO is in use, fail
> the buffer mode.
I'd kind of assume that anyone using these GPIOs is doing it in a fashion
related closely to the ADC itself.
Can we make any other use fail more cleanly?
J
>