lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 19 Feb 2015 21:33:44 -0800
From:	Dmitry Torokhov <dmitry.torokhov@...il.com>
To:	Alexandre Courbot <gnurou@...il.com>
Cc:	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>,
	Linus Walleij <linus.walleij@...aro.org>,
	"linux-gpio@...r.kernel.org" <linux-gpio@...r.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] gpio: return NULL from gpiod_get_optional when GPIOLIB
 is disabled

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@...il.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.

> 
> I should have commented at that time, but let's do it now: I agree
> with the idea, but this leaves the door open to confusing situations
> in case gpiolib was unintentionally disabled. Could you also add a
> note in the documentation of this function to explain this behavior,
> to spare a few headaches to users of this function?

You mean the inline documentation in drivers/gpio/gpiolib.c and
drivers/gpio/devres.c? I can certainly mention there that is GPIOLIB is disabled
thy will return NULL unlike the non-optional variants.

> 
> >
> > Signed-off-by: Dmitry Torokhov <dmitry.torokhov@...il.com>
> > ---
> >  include/linux/gpio/consumer.h | 8 ++++----
> >  1 file changed, 4 insertions(+), 4 deletions(-)
> >
> > diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
> > index fd85cb1..f68244f 100644
> > --- a/include/linux/gpio/consumer.h
> > +++ b/include/linux/gpio/consumer.h
> > @@ -132,14 +132,14 @@ static inline struct gpio_desc *__must_check
> >  __gpiod_get_optional(struct device *dev, const char *con_id,
> >                      enum gpiod_flags flags)
> >  {
> > -       return ERR_PTR(-ENOSYS);
> > +       return NULL;
> >  }
> >
> >  static inline struct gpio_desc *__must_check
> >  __gpiod_get_index_optional(struct device *dev, const char *con_id,
> >                            unsigned int index, enum gpiod_flags flags)
> >  {
> > -       return ERR_PTR(-ENOSYS);
> > +       return NULL;
> >  }
> >
> >  static inline void gpiod_put(struct gpio_desc *desc)
> > @@ -171,14 +171,14 @@ static inline struct gpio_desc *__must_check
> >  __devm_gpiod_get_optional(struct device *dev, const char *con_id,
> >                           enum gpiod_flags flags)
> >  {
> > -       return ERR_PTR(-ENOSYS);
> > +       return NULL;
> >  }
> >
> >  static inline struct gpio_desc *__must_check
> >  __devm_gpiod_get_index_optional(struct device *dev, const char *con_id,
> >                                 unsigned int index, enum gpiod_flags flags)
> >  {
> > -       return ERR_PTR(-ENOSYS);
> > +       return NULL;
> >  }
> >
> >  static inline void devm_gpiod_put(struct device *dev, struct gpio_desc *desc)
> > --
> > 2.2.0.rc0.207.ga3a616c
> >
> >
> > --
> > Dmitry

-- 
Dmitry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ