From: Matteo Croce Date: Sat, 12 Jan 2008 16:41:28 +0000 (+0000) Subject: cache GPIO addresses to be more efficent X-Git-Tag: reboot~27234 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=fae9e82aad968f65cf2d8b3a8f5db11f3f1e88d6;p=oweals%2Fopenwrt.git cache GPIO addresses to be more efficent SVN-Revision: 10179 --- diff --git a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h index 2e19fcae9d..7d665ff62d 100644 --- a/target/linux/ar7/files/include/asm-mips/ar7/gpio.h +++ b/target/linux/ar7/files/include/asm-mips/ar7/gpio.h @@ -28,19 +28,28 @@ extern void gpio_free(unsigned gpio); /* Common GPIO layer */ static inline int gpio_get_value(unsigned gpio) { - void __iomem *gpio_in = - (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT); + static unsigned addr; - return readl(gpio_in) & (1 << gpio); + if (!addr) { + void __iomem *gpio_in = (void __iomem *) + KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_INPUT); + addr = readl(gpio_in); + } + + return addr & (1 << gpio); } static inline void gpio_set_value(unsigned gpio, int value) { + static unsigned addr; + unsigned tmp; + void __iomem *gpio_out = (void __iomem *)KSEG1ADDR(AR7_REGS_GPIO + AR7_GPIO_OUTPUT); - unsigned tmp; + if (!addr) + addr = readl(gpio_out); - tmp = readl(gpio_out) & ~(1 << gpio); + tmp = addr & ~(1 << gpio); if (value) tmp |= 1 << gpio; writel(tmp, gpio_out);