aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Simek2018-07-30 14:29:27 +0200
committerMichal Simek2018-08-07 11:03:43 +0200
commit642a86041228974c154dc7e250f3d1e0b8adf33f (patch)
tree5919c1f2d7cf5d6b5dc99168040dbc5a54f6fdbe
parentbf2a69de81908f36a5853b36cc2afbd976856e3b (diff)
gpio: xilinx: Simplify logic in xilinx_gpio_set_value
There is no reason to do read/write for if/else separately. Reported-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net> Signed-off-by: Michal Simek <michal.simek@xilinx.com> Reviewed-by: Stefan Herbrechtsmeier <stefan@herbrechtsmeier.net>
-rw-r--r--drivers/gpio/xilinx_gpio.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c
index 1e5f3da8d7e..cccfa756173 100644
--- a/drivers/gpio/xilinx_gpio.c
+++ b/drivers/gpio/xilinx_gpio.c
@@ -61,18 +61,17 @@ static int xilinx_gpio_set_value(struct udevice *dev, unsigned offset,
if (ret)
return ret;
+ val = readl(&platdata->regs->gpiodata + bank * 2);
+
debug("%s: regs: %lx, value: %x, gpio: %x, bank %x, pin %x\n",
__func__, (ulong)platdata->regs, value, offset, bank, pin);
- if (value) {
- val = readl(&platdata->regs->gpiodata + bank * 2);
+ if (value)
val = val | (1 << pin);
- writel(val, &platdata->regs->gpiodata + bank * 2);
- } else {
- val = readl(&platdata->regs->gpiodata + bank * 2);
+ else
val = val & ~(1 << pin);
- writel(val, &platdata->regs->gpiodata + bank * 2);
- }
+
+ writel(val, &platdata->regs->gpiodata + bank * 2);
return val;
};