Re: [PATCH v2] staging: iio: adc: ad7816: Use devm_gpiod_get_optional() for busy GPIO
From: Andy Shevchenko
Date: Wed Jun 03 2026 - 06:40:46 EST
On Wed, Jun 03, 2026 at 01:20:08PM +0300, Dan Carpenter wrote:
> On Wed, Jun 03, 2026 at 12:26:11PM +0300, Andy Shevchenko wrote:
> > On Wed, Jun 03, 2026 at 12:33:33PM +0000, Taha Narimani wrote:
...
> > > - if (chip->id == ID_AD7817) {
> > > + if (chip->busy_pin) {
> >
> > If we get GPIO optional, this check wouldn't be necessary anymore as the below
> > should return 0 IIRC in this case.
>
> No, it's still necessary. It can be NULL because of the CONFIG_
> in which case, sure, gpiod_get_value() is a no-op. But it can
> also be NULL because of the device tree and in that case we need
> the check to avoid a NULL pointer dereference.
Can you elaborate on the latter more? I fail to see that.
What I see is that the function either implemented or not is NULL-aware.
> > > while (gpiod_get_value(chip->busy_pin))
> > > cpu_relax();
> > > }
--
With Best Regards,
Andy Shevchenko