diff options
author | Andrey Smirnov <andrew.smirnov@gmail.com> | 2019-03-11 02:27:33 -0400 |
---|---|---|
committer | Bartosz Golaszewski <bgolaszewski@baylibre.com> | 2019-03-18 03:58:45 -0400 |
commit | 4a8909d0228133ec02ffac76590c055e593e8185 (patch) | |
tree | 5db0d1eb31d0242a12e24dece6e0a573ba7b62b4 | |
parent | a262555bc68561dc861cb24d3bd432fd6ce4f868 (diff) |
gpio: vf610: Simplify vf610_gpio_get()
Both branches of the if statement do exactly the same thing, just at
different offsets. Simplify the code a bit by moving shared action
code outside of the if statement. No functional change intended.
Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Chris Healy <cphealy@gmail.com>
Cc: Andrew Lunn <andrew@lunn.ch>
Cc: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Fabio Estevam <festevam@gmail.com>
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-imx@nxp.com
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
-rw-r--r-- | drivers/gpio/gpio-vf610.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/gpio/gpio-vf610.c b/drivers/gpio/gpio-vf610.c index 2ea17870e9da..bb35cedd05e3 100644 --- a/drivers/gpio/gpio-vf610.c +++ b/drivers/gpio/gpio-vf610.c | |||
@@ -85,17 +85,15 @@ static int vf610_gpio_get(struct gpio_chip *gc, unsigned int gpio) | |||
85 | { | 85 | { |
86 | struct vf610_gpio_port *port = gpiochip_get_data(gc); | 86 | struct vf610_gpio_port *port = gpiochip_get_data(gc); |
87 | unsigned long mask = BIT(gpio); | 87 | unsigned long mask = BIT(gpio); |
88 | void __iomem *addr; | 88 | unsigned long offset = GPIO_PDIR; |
89 | 89 | ||
90 | if (port->sdata && port->sdata->have_paddr) { | 90 | if (port->sdata && port->sdata->have_paddr) { |
91 | mask &= vf610_gpio_readl(port->gpio_base + GPIO_PDDR); | 91 | mask &= vf610_gpio_readl(port->gpio_base + GPIO_PDDR); |
92 | addr = mask ? port->gpio_base + GPIO_PDOR : | 92 | if (mask) |
93 | port->gpio_base + GPIO_PDIR; | 93 | offset = GPIO_PDOR; |
94 | return !!(vf610_gpio_readl(addr) & BIT(gpio)); | ||
95 | } else { | ||
96 | return !!(vf610_gpio_readl(port->gpio_base + GPIO_PDIR) | ||
97 | & BIT(gpio)); | ||
98 | } | 94 | } |
95 | |||
96 | return !!(vf610_gpio_readl(port->gpio_base + offset) & BIT(gpio)); | ||
99 | } | 97 | } |
100 | 98 | ||
101 | static void vf610_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) | 99 | static void vf610_gpio_set(struct gpio_chip *gc, unsigned int gpio, int val) |