gpiolib: gpio_name_to_desc: factor out !name check
authorMichał Mirosław <mirq-linux@rere.qmqm.pl>
Sun, 15 Mar 2020 16:34:34 +0000 (17:34 +0100)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Wed, 25 Mar 2020 08:50:46 +0000 (09:50 +0100)
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>
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
drivers/gpio/gpiolib.c

index 00890f38f95f6838499541aeeac3ee530906e157..c7ee224bcb864951403a5482490e05235052eeef 100644 (file)
@@ -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)) {