Re: [PATCH v2] gpio: return NULL from gpiod_get_optional when GPIOLIB is disabled

From: Linus Walleij
Date: Tue Mar 14 2017 - 09:31:14 EST


On Mon, Feb 13, 2017 at 2:13 AM, Dmitry Torokhov
<dmitry.torokhov@xxxxxxxxx> wrote:

> Given the intent behind gpiod_get_optional() and friends it does not make
> sense to return -ENOSYS when GPIOLIB is disabled: the driver is expected to
> work just fine without gpio so let's behave as if gpio was not found.
> Otherwise we have to special-case -ENOSYS in drivers.
>
> Note that there was objection that someone might forget to enable GPIOLIB
> when dealing with a platform that has device that actually specifies
> optional gpio and we'll break it. I find this unconvincing as that would
> have to be the *only GPIO* in the system, which is extremely unlikely.
>
> Suggested-by: Uwe Kleine-KÃnig <u.kleine-koenig@xxxxxxxxxxxxxx>
> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
> ---
>
> This is a resend of a similar patch from a couple years ago.
>
> V2:

After a lot of decision angst I applied this patch, dropping Uwe's
Suggested-by since he doesn't seem to like it.

I think we should eventually return proper error codes,
but as you say: the API should be consistent first, we need
to change both the lib and the stubs to return error codes
for that, this is about something else, just keeping it consistent.

Yours,
Linus Walleij