From: Michal Simek Date: Mon, 30 Jul 2018 12:29:27 +0000 (+0200) Subject: gpio: xilinx: Simplify logic in xilinx_gpio_set_value X-Git-Tag: v2025.01-rc5-pxa1908~3800^2~5 X-Git-Url: http://git.dujemihanovic.xyz/%7B%7B%20%24style.RelPermalink%20%7D%7D?a=commitdiff_plain;h=642a86041228974c154dc7e250f3d1e0b8adf33f;p=u-boot.git 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 Signed-off-by: Michal Simek Reviewed-by: Stefan Herbrechtsmeier --- diff --git a/drivers/gpio/xilinx_gpio.c b/drivers/gpio/xilinx_gpio.c index 1e5f3da8d7..cccfa75617 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; };