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, 1 May 2014 15:02:07 +0900
From:	Alexandre Courbot <gnurou@...il.com>
To:	Thierry Reding <thierry.reding@...il.com>
Cc:	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 2/2] gpio: Add helpers for optional GPIOs

On Sat, Apr 26, 2014 at 12:10 AM, Thierry Reding
<thierry.reding@...il.com> wrote:
> From: Thierry Reding <treding@...dia.com>
>
> Introduce gpiod_get_optional() and gpiod_get_index_optional() helpers
> that make it easier for drivers to handle optional GPIOs.
>
> Currently in order to handle optional GPIOs, a driver needs to special
> case error handling for -ENOENT, such as this:
>
>         gpio = gpiod_get(dev, "foo");
>         if (IS_ERR(gpio)) {
>                 if (PTR_ERR(gpio) != -ENOENT)
>                         return PTR_ERR(gpio);
>
>                 gpio = NULL;
>         }
>
>         if (gpio) {
>                 /* set up GPIO */
>         }
>
> With these new helpers the above is reduced to:
>
>         gpio = gpiod_get_optional(dev, "foo");
>         if (IS_ERR(gpio))
>                 return PTR_ERR(gpio);
>
>         if (gpio) {
>                 /* set up GPIO */
>         }
>
> While at it, device-managed variants of these functions are also
> provided.

Patch is sound and the introduced functions are useful indeed.

Reviewed-by: Alexandre Courbot <acourbot@...dia.com>

It makes me wonder whether this should not have been the behavior of
gpiod_get() directly... My aversion for IS_ERR_OR_NULL drove the
current design, which may not have been optimal.

Oh, well.
--
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