gpio: xilinx: Simplify logic in xilinx_gpio_set_value
authorMichal Simek <michal.simek@xilinx.com>
Mon, 30 Jul 2018 12:29:27 +0000 (14:29 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 7 Aug 2018 09:03:43 +0000 (11:03 +0200)
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>
drivers/gpio/xilinx_gpio.c

index 1e5f3da8d7e810c229c57e1bc2bb267e76e78e32..cccfa75617395ce299a69c563316f4847960584f 100644 (file)
@@ -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;
 };