linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpiolib: gpio_name_to_desc: factor out !name check
@ 2020-03-15 16:34 Michał Mirosław
  2020-03-16 10:28 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Mirosław @ 2020-03-15 16:34 UTC (permalink / raw)
  To: Linus Walleij, Bartosz Golaszewski; +Cc: linux-gpio, linux-kernel

Since name == NULL can't ever match, move the check out of
IRQ-disabled region.

Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
---
 drivers/gpio/gpiolib.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 175c6363cf61..20fbeffbdd91 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -301,6 +301,9 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)
 	struct gpio_device *gdev;
 	unsigned long flags;
 
+	if (!name)
+		return NULL;
+
 	spin_lock_irqsave(&gpio_lock, flags);
 
 	list_for_each_entry(gdev, &gpio_devices, list) {
@@ -309,7 +312,7 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)
 		for (i = 0; i != gdev->ngpio; ++i) {
 			struct gpio_desc *desc = &gdev->descs[i];
 
-			if (!desc->name || !name)
+			if (!desc->name)
 				continue;
 
 			if (!strcmp(desc->name, name)) {
-- 
2.20.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] gpiolib: gpio_name_to_desc: factor out !name check
  2020-03-15 16:34 [PATCH] gpiolib: gpio_name_to_desc: factor out !name check Michał Mirosław
@ 2020-03-16 10:28 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2020-03-16 10:28 UTC (permalink / raw)
  To: Michał Mirosław
  Cc: Linus Walleij, Bartosz Golaszewski, open list:GPIO SUBSYSTEM,
	Linux Kernel Mailing List

niedz., 15 mar 2020 o 17:34 Michał Mirosław <mirq-linux@rere.qmqm.pl>
napisał(a):
>
> Since name == NULL can't ever match, move the check out of
> IRQ-disabled region.
>
> Signed-off-by: Michał Mirosław <mirq-linux@rere.qmqm.pl>
> ---
>  drivers/gpio/gpiolib.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 175c6363cf61..20fbeffbdd91 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -301,6 +301,9 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)
>         struct gpio_device *gdev;
>         unsigned long flags;
>
> +       if (!name)
> +               return NULL;
> +
>         spin_lock_irqsave(&gpio_lock, flags);
>
>         list_for_each_entry(gdev, &gpio_devices, list) {
> @@ -309,7 +312,7 @@ static struct gpio_desc *gpio_name_to_desc(const char * const name)
>                 for (i = 0; i != gdev->ngpio; ++i) {
>                         struct gpio_desc *desc = &gdev->descs[i];
>
> -                       if (!desc->name || !name)
> +                       if (!desc->name)
>                                 continue;
>
>                         if (!strcmp(desc->name, name)) {
> --
> 2.20.1
>

Patch applied, thanks!

Bartosz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-03-16 10:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-15 16:34 [PATCH] gpiolib: gpio_name_to_desc: factor out !name check Michał Mirosław
2020-03-16 10:28 ` Bartosz Golaszewski

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).