Messages in this thread | | | Date | Fri, 20 Feb 2015 19:54:02 +0100 | From | Uwe Kleine-König <> | Subject | Re: [PATCH] gpio: return NULL from gpiod_get_optional when GPIOLIB is disabled |
| |
Hello,
On Thu, Feb 19, 2015 at 09:33:44PM -0800, Dmitry Torokhov wrote: > On Fri, Feb 20, 2015 at 01:59:43PM +0900, Alexandre Courbot wrote: > > On Fri, Feb 20, 2015 at 9:30 AM, Dmitry Torokhov > > <dmitry.torokhov@gmail.com> 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. > > > > Interestingly Uwe sent a RFC for this one week ago: > > > > http://patchwork.ozlabs.org/patch/439135/ > > > > Maybe credit him with a Suggested-by.? > > I certainly am fine with crediting him with Suggested-by even though I did not > see that Uwe's e-mail but this patch was prompted by his other patch changing a > few input drivers to use gpiod_get_optional() and me recalling that I > explicitly did not use it as it made no difference from gpiod_get() since I had > to handle -ENOSYS anyway. Note that I'm not convinced any more this is a good idea. Consider you have a device tree entry specifying
reset-gpio = <&gpio5 4 0>;
for your device.
With
gpiod_get_optional(dev, "reset", GPIO_OUT_LOW);
the drivers tells that some of the devices it can handle have a reset gpio. If the device in question does have such a gpio the driver must know and do something with it. If the device doesn't have such a gpio that's fine, too.
But if GPIOLIB is off and the device has a reset-gpio specified you certainly want to error out, right?
So IMHO the right thing to do is to return NULL iff there is no reset-gpio specified. Otherwise -ENOSYS is the right thing to return.
Best regards Uwe
-- Pengutronix e.K. | Uwe Kleine-König | Industrial Linux Solutions | http://www.pengutronix.de/ |
| |