gpio: xilinx: Set value before changing direction
authorMichal Simek <michal.simek@xilinx.com>
Mon, 30 Jul 2018 08:02:53 +0000 (10:02 +0200)
committerMichal Simek <michal.simek@xilinx.com>
Tue, 7 Aug 2018 09:03:43 +0000 (11:03 +0200)
Set a value before changing gpio direction. This will ensure that the
old value is not propagated when direction has changed but new value is
not written yet.

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 776a147cc8d72c7d302043bef6ffb3c0f1c6d1b6..1e5f3da8d7e810c229c57e1bc2bb267e76e78e32 100644 (file)
@@ -139,14 +139,14 @@ static int xilinx_gpio_direction_output(struct udevice *dev, unsigned offset,
        if (platdata->bank_input[bank])
                return -EINVAL;
 
+       xilinx_gpio_set_value(dev, offset, value);
+
        if (!platdata->bank_output[bank]) {
                val = readl(&platdata->regs->gpiodir + bank * 2);
                val = val & ~(1 << pin);
                writel(val, &platdata->regs->gpiodir + bank * 2);
        }
 
-       xilinx_gpio_set_value(dev, offset, value);
-
        return 0;
 }