OSDN Git Service

gpio: omap: simplify omap_gpio_get_direction()
authorRussell King <rmk+kernel@armlinux.org.uk>
Mon, 10 Jun 2019 17:10:50 +0000 (20:10 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 12 Jun 2019 09:13:41 +0000 (11:13 +0200)
Architectures are single-copy atomic, which means that simply reading
a register is an inherently atomic operation.  There is no need to
take a spinlock here.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
Tested-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpio-omap.c

index cc320d0..44a4287 100644 (file)
@@ -953,17 +953,10 @@ static void omap_gpio_free(struct gpio_chip *chip, unsigned offset)
 
 static int omap_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
 {
-       struct gpio_bank *bank;
-       unsigned long flags;
-       void __iomem *reg;
-       int dir;
+       struct gpio_bank *bank = gpiochip_get_data(chip);
 
-       bank = gpiochip_get_data(chip);
-       reg = bank->base + bank->regs->direction;
-       raw_spin_lock_irqsave(&bank->lock, flags);
-       dir = !!(readl_relaxed(reg) & BIT(offset));
-       raw_spin_unlock_irqrestore(&bank->lock, flags);
-       return dir;
+       return !!(readl_relaxed(bank->base + bank->regs->direction) &
+                 BIT(offset));
 }
 
 static int omap_gpio_input(struct gpio_chip *chip, unsigned offset)