linux-mips
[Top] [All Lists]

[PATCH 2/2] MIPS: ath79: simplify ath79_gpio_function_* routines

To: Ralf Baechle <ralf@linux-mips.org>
Subject: [PATCH 2/2] MIPS: ath79: simplify ath79_gpio_function_* routines
From: Gabor Juhos <juhosg@openwrt.org>
Date: Tue, 29 Jan 2013 10:19:13 +0100
Cc: John Crispin <blogic@openwrt.org>, linux-mips <linux-mips@linux-mips.org>, Gabor Juhos <juhosg@openwrt.org>
In-reply-to: <1359451153-13335-1-git-send-email-juhosg@openwrt.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
References: <1359451153-13335-1-git-send-email-juhosg@openwrt.org>
Sender: linux-mips-bounce@linux-mips.org
Make ath79_gpio_function_{en,dis}able to be wrappers
around ath79_gpio_function_setup.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
---
 arch/mips/ath79/gpio.c |   30 ++++++------------------------
 1 file changed, 6 insertions(+), 24 deletions(-)

diff --git a/arch/mips/ath79/gpio.c b/arch/mips/ath79/gpio.c
index 662a10e..b7ed207 100644
--- a/arch/mips/ath79/gpio.c
+++ b/arch/mips/ath79/gpio.c
@@ -154,46 +154,28 @@ static void __iomem *ath79_gpio_get_function_reg(void)
        return ath79_gpio_base + reg;
 }
 
-void ath79_gpio_function_enable(u32 mask)
+void ath79_gpio_function_setup(u32 set, u32 clear)
 {
        void __iomem *reg = ath79_gpio_get_function_reg();
        unsigned long flags;
 
        spin_lock_irqsave(&ath79_gpio_lock, flags);
 
-       __raw_writel(__raw_readl(reg) | mask, reg);
+       __raw_writel((__raw_readl(reg) & ~clear) | set, reg);
        /* flush write */
        __raw_readl(reg);
 
        spin_unlock_irqrestore(&ath79_gpio_lock, flags);
 }
 
-void ath79_gpio_function_disable(u32 mask)
+void ath79_gpio_function_enable(u32 mask)
 {
-       void __iomem *reg = ath79_gpio_get_function_reg();
-       unsigned long flags;
-
-       spin_lock_irqsave(&ath79_gpio_lock, flags);
-
-       __raw_writel(__raw_readl(reg) & ~mask, reg);
-       /* flush write */
-       __raw_readl(reg);
-
-       spin_unlock_irqrestore(&ath79_gpio_lock, flags);
+       ath79_gpio_function_setup(mask, 0);
 }
 
-void ath79_gpio_function_setup(u32 set, u32 clear)
+void ath79_gpio_function_disable(u32 mask)
 {
-       void __iomem *reg = ath79_gpio_get_function_reg();
-       unsigned long flags;
-
-       spin_lock_irqsave(&ath79_gpio_lock, flags);
-
-       __raw_writel((__raw_readl(reg) & ~clear) | set, reg);
-       /* flush write */
-       __raw_readl(reg);
-
-       spin_unlock_irqrestore(&ath79_gpio_lock, flags);
+       ath79_gpio_function_setup(0, mask);
 }
 
 void __init ath79_gpio_init(void)
-- 
1.7.10


<Prev in Thread] Current Thread [Next in Thread>