[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20190610171103.30903-10-grygorii.strashko@ti.com>
Date: Mon, 10 Jun 2019 20:10:52 +0300
From: Grygorii Strashko <grygorii.strashko@...com>
To: Russell King <rmk@....linux.org.uk>,
Linus Walleij <linus.walleij@...aro.org>,
Tony Lindgren <tony@...mide.com>
CC: Bartosz Golaszewski <bgolaszewski@...libre.com>,
<linux-omap@...r.kernel.org>, <linux-gpio@...r.kernel.org>,
<linux-kernel@...r.kernel.org>,
Santosh Shilimkar <ssantosh@...nel.org>,
Russell King <rmk+kernel@...linux.org.uk>,
Grygorii Strashko <grygorii.strashko@...com>
Subject: [PATCH-next 09/20] gpio: gpio-omap: simplify get_multiple()
From: Russell King <rmk+kernel@...linux.org.uk>
There is no reason to have helper functions to read the datain and
dataout registers when they are only used in one location. Simplify
this code to make it more readable.
Signed-off-by: Russell King <rmk+kernel@...linux.org.uk>
Signed-off-by: Grygorii Strashko <grygorii.strashko@...com>
---
drivers/gpio/gpio-omap.c | 36 +++++++++++-------------------------
1 file changed, 11 insertions(+), 25 deletions(-)
diff --git a/drivers/gpio/gpio-omap.c b/drivers/gpio/gpio-omap.c
index bf1e6f1d0de7..a26decc5c611 100644
--- a/drivers/gpio/gpio-omap.c
+++ b/drivers/gpio/gpio-omap.c
@@ -175,22 +175,6 @@ static void omap_set_gpio_dataout_mask_multiple(struct gpio_bank *bank,
bank->context.dataout = l;
}
-static unsigned long omap_get_gpio_datain_multiple(struct gpio_bank *bank,
- unsigned long *mask)
-{
- void __iomem *reg = bank->base + bank->regs->datain;
-
- return readl_relaxed(reg) & *mask;
-}
-
-static unsigned long omap_get_gpio_dataout_multiple(struct gpio_bank *bank,
- unsigned long *mask)
-{
- void __iomem *reg = bank->base + bank->regs->dataout;
-
- return readl_relaxed(reg) & *mask;
-}
-
static inline void omap_gpio_rmw(void __iomem *base, u32 reg, u32 mask, bool set)
{
int l = readl_relaxed(base + reg);
@@ -987,18 +971,20 @@ static int omap_gpio_get_multiple(struct gpio_chip *chip, unsigned long *mask,
unsigned long *bits)
{
struct gpio_bank *bank = gpiochip_get_data(chip);
- void __iomem *reg = bank->base + bank->regs->direction;
- unsigned long in = readl_relaxed(reg), l;
+ void __iomem *base = bank->base;
+ u32 direction, m, val = 0;
+
+ direction = readl_relaxed(base + bank->regs->direction);
- *bits = 0;
+ m = direction & *mask;
+ if (m)
+ val |= readl_relaxed(base + bank->regs->datain) & m;
- l = in & *mask;
- if (l)
- *bits |= omap_get_gpio_datain_multiple(bank, &l);
+ m = ~direction & *mask;
+ if (m)
+ val |= readl_relaxed(base + bank->regs->dataout) & m;
- l = ~in & *mask;
- if (l)
- *bits |= omap_get_gpio_dataout_multiple(bank, &l);
+ *bits = val;
return 0;
}
--
2.17.1
Powered by blists - more mailing lists