From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755266AbbBTSyI (ORCPT ); Fri, 20 Feb 2015 13:54:08 -0500 Received: from metis.ext.pengutronix.de ([92.198.50.35]:51722 "EHLO metis.ext.pengutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754889AbbBTSyG (ORCPT ); Fri, 20 Feb 2015 13:54:06 -0500 Date: Fri, 20 Feb 2015 19:54:02 +0100 From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= To: Dmitry Torokhov Cc: Alexandre Courbot , Linus Walleij , "linux-gpio@vger.kernel.org" , Linux Kernel Mailing List Subject: Re: [PATCH] gpio: return NULL from gpiod_get_optional when GPIOLIB is disabled Message-ID: <20150220185402.GQ19388@pengutronix.de> References: <20150220003035.GA22334@dtor-glaptop> <20150220053344.GA5518@dtor-glaptop> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20150220053344.GA5518@dtor-glaptop> User-Agent: Mutt/1.5.21 (2010-09-15) X-SA-Exim-Connect-IP: 2001:67c:670:100:1d::c0 X-SA-Exim-Mail-From: ukl@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > > 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/ |