gpio: refactor gpiochip_find() slightly
authorMasahiro Yamada <yamada.masahiro@socionext.com>
Thu, 11 Aug 2016 16:21:58 +0000 (01:21 +0900)
committerLinus Walleij <linus.walleij@linaro.org>
Fri, 19 Aug 2016 08:55:08 +0000 (10:55 +0200)
The if...else... block after the loop can be dropped with
a slight refactoring.

Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib.c

index 53ff25ac66d8c49df53c41cdd1efff693ea90751..deaf4d4dc68e9a22f449b085d274386c17119a36 100644 (file)
@@ -1363,19 +1363,15 @@ struct gpio_chip *gpiochip_find(void *data,
                                             void *data))
 {
        struct gpio_device *gdev;
-       struct gpio_chip *chip;
+       struct gpio_chip *chip = NULL;
        unsigned long flags;
 
        spin_lock_irqsave(&gpio_lock, flags);
        list_for_each_entry(gdev, &gpio_devices, list)
-               if (gdev->chip && match(gdev->chip, data))
+               if (gdev->chip && match(gdev->chip, data)) {
+                       chip = gdev->chip;
                        break;
-
-       /* No match? */
-       if (&gdev->list == &gpio_devices)
-               chip = NULL;
-       else
-               chip = gdev->chip;
+               }
 
        spin_unlock_irqrestore(&gpio_lock, flags);