Skip to content

Commit

Permalink
gpio: refactor gpiochip_find() slightly
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Masahiro Yamada authored and Linus Walleij committed Aug 19, 2016
1 parent 05cc995 commit acf06ff
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit acf06ff

Please sign in to comment.