linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: Alexandre Courbot <gnurou@gmail.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	"linux-gpio@vger.kernel.org" <linux-gpio@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] gpio: return NULL from gpiod_get_optional when GPIOLIB is disabled
Date: Fri, 20 Feb 2015 19:54:02 +0100	[thread overview]
Message-ID: <20150220185402.GQ19388@pengutronix.de> (raw)
In-Reply-To: <20150220053344.GA5518@dtor-glaptop>

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/  |
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

      parent reply	other threads:[~2015-02-20 18:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-02-20  0:30 [PATCH] gpio: return NULL from gpiod_get_optional when GPIOLIB is disabled Dmitry Torokhov
2015-02-20  4:59 ` Alexandre Courbot
2015-02-20  5:33   ` Dmitry Torokhov
2015-02-20  5:37     ` Alexandre Courbot
2015-02-20 18:54     ` Uwe Kleine-König [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20150220185402.GQ19388@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=dmitry.torokhov@gmail.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).