* [PATCH] Watchdog: mtx-1: fix abuse of gpio registers
@ 2011-05-09 19:18 Manuel Lauss
2011-05-12 12:52 ` Florian Fainelli
2011-05-13 19:25 ` Manuel Lauss
0 siblings, 2 replies; 3+ messages in thread
From: Manuel Lauss @ 2011-05-09 19:18 UTC (permalink / raw)
To: Wim Van Sebroeck, linux-watchdog; +Cc: Florian Fainelli, Manuel Lauss
This patch replaces the drivers racy abuse of the gpio2 direction
register with calls to the gpio library.
Cc: Florian Fainelli <florian@openwrt.org>
Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
---
drivers/watchdog/mtx-1_wdt.c | 17 ++++++++++-------
1 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
index 5ec5ac1..011fee4 100644
--- a/drivers/watchdog/mtx-1_wdt.c
+++ b/drivers/watchdog/mtx-1_wdt.c
@@ -66,6 +66,7 @@ static struct {
int default_ticks;
unsigned long inuse;
unsigned gpio;
+ int gstate;
} mtx1_wdt_device;
static void mtx1_wdt_trigger(unsigned long unused)
@@ -75,13 +76,13 @@ static void mtx1_wdt_trigger(unsigned long unused)
spin_lock(&mtx1_wdt_device.lock);
if (mtx1_wdt_device.running)
ticks--;
- /*
- * toggle GPIO2_15
- */
- tmp = au_readl(GPIO2_DIR);
- tmp = (tmp & ~(1 << mtx1_wdt_device.gpio)) |
- ((~tmp) & (1 << mtx1_wdt_device.gpio));
- au_writel(tmp, GPIO2_DIR);
+
+ /* toggle wdt gpio */
+ mtx1_wdt_device.gstate = ~mtx1_wdt_device.gstate;
+ if (mtx1_wdt_device.gstate)
+ gpio_direction_output(mtx1_wdt_device.gpio, 1);
+ else
+ gpio_direction_input(mtx1_wdt_device.gpio);
if (mtx1_wdt_device.queue && ticks)
mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
@@ -103,6 +104,7 @@ static void mtx1_wdt_start(void)
spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
if (!mtx1_wdt_device.queue) {
mtx1_wdt_device.queue = 1;
+ mtx1_wdt_device.gstate = 1;
gpio_set_value(mtx1_wdt_device.gpio, 1);
mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
}
@@ -117,6 +119,7 @@ static int mtx1_wdt_stop(void)
spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
if (mtx1_wdt_device.queue) {
mtx1_wdt_device.queue = 0;
+ mtx1_wdt_device.gstate = 0;
gpio_set_value(mtx1_wdt_device.gpio, 0);
}
ticks = mtx1_wdt_device.default_ticks;
--
1.7.5.rc3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Watchdog: mtx-1: fix abuse of gpio registers
2011-05-09 19:18 [PATCH] Watchdog: mtx-1: fix abuse of gpio registers Manuel Lauss
@ 2011-05-12 12:52 ` Florian Fainelli
2011-05-13 19:25 ` Manuel Lauss
1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2011-05-12 12:52 UTC (permalink / raw)
To: Manuel Lauss; +Cc: Wim Van Sebroeck, linux-watchdog
Hello Manuel,
On Monday 09 May 2011 21:18:34 Manuel Lauss wrote:
> This patch replaces the drivers racy abuse of the gpio2 direction
> register with calls to the gpio library.
>
> Cc: Florian Fainelli <florian@openwrt.org>
> Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
I will give a try at this patch, it looks good at first glance.
> ---
> drivers/watchdog/mtx-1_wdt.c | 17 ++++++++++-------
> 1 files changed, 10 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/watchdog/mtx-1_wdt.c b/drivers/watchdog/mtx-1_wdt.c
> index 5ec5ac1..011fee4 100644
> --- a/drivers/watchdog/mtx-1_wdt.c
> +++ b/drivers/watchdog/mtx-1_wdt.c
> @@ -66,6 +66,7 @@ static struct {
> int default_ticks;
> unsigned long inuse;
> unsigned gpio;
> + int gstate;
> } mtx1_wdt_device;
>
> static void mtx1_wdt_trigger(unsigned long unused)
> @@ -75,13 +76,13 @@ static void mtx1_wdt_trigger(unsigned long unused)
> spin_lock(&mtx1_wdt_device.lock);
> if (mtx1_wdt_device.running)
> ticks--;
> - /*
> - * toggle GPIO2_15
> - */
> - tmp = au_readl(GPIO2_DIR);
> - tmp = (tmp & ~(1 << mtx1_wdt_device.gpio)) |
> - ((~tmp) & (1 << mtx1_wdt_device.gpio));
> - au_writel(tmp, GPIO2_DIR);
> +
> + /* toggle wdt gpio */
> + mtx1_wdt_device.gstate = ~mtx1_wdt_device.gstate;
> + if (mtx1_wdt_device.gstate)
> + gpio_direction_output(mtx1_wdt_device.gpio, 1);
> + else
> + gpio_direction_input(mtx1_wdt_device.gpio);
>
> if (mtx1_wdt_device.queue && ticks)
> mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
> @@ -103,6 +104,7 @@ static void mtx1_wdt_start(void)
> spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
> if (!mtx1_wdt_device.queue) {
> mtx1_wdt_device.queue = 1;
> + mtx1_wdt_device.gstate = 1;
> gpio_set_value(mtx1_wdt_device.gpio, 1);
> mod_timer(&mtx1_wdt_device.timer, jiffies + MTX1_WDT_INTERVAL);
> }
> @@ -117,6 +119,7 @@ static int mtx1_wdt_stop(void)
> spin_lock_irqsave(&mtx1_wdt_device.lock, flags);
> if (mtx1_wdt_device.queue) {
> mtx1_wdt_device.queue = 0;
> + mtx1_wdt_device.gstate = 0;
> gpio_set_value(mtx1_wdt_device.gpio, 0);
> }
> ticks = mtx1_wdt_device.default_ticks;
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Watchdog: mtx-1: fix abuse of gpio registers
2011-05-09 19:18 [PATCH] Watchdog: mtx-1: fix abuse of gpio registers Manuel Lauss
2011-05-12 12:52 ` Florian Fainelli
@ 2011-05-13 19:25 ` Manuel Lauss
1 sibling, 0 replies; 3+ messages in thread
From: Manuel Lauss @ 2011-05-13 19:25 UTC (permalink / raw)
To: Wim Van Sebroeck, linux-watchdog; +Cc: Florian Fainelli
On Mon, May 9, 2011 at 9:18 PM, Manuel Lauss
<manuel.lauss@googlemail.com> wrote:
> This patch replaces the drivers racy abuse of the gpio2 direction
> register with calls to the gpio library.
>
> Cc: Florian Fainelli <florian@openwrt.org>
> Signed-off-by: Manuel Lauss <manuel.lauss@googlemail.com>
> ---
> drivers/watchdog/mtx-1_wdt.c | 17 ++++++++++-------
> 1 files changed, 10 insertions(+), 7 deletions(-)
Please disregard this patch. It depends on another change to the mtx-1
platform files, and Ralf Baechle already included it in the MIPS tree
(as part of a larger patch to the Alchemy infrastructure) for 2.6.40.
Thanks,
Manuel Lauss
--
To unsubscribe from this list: send the line "unsubscribe linux-watchdog" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-05-13 19:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-09 19:18 [PATCH] Watchdog: mtx-1: fix abuse of gpio registers Manuel Lauss
2011-05-12 12:52 ` Florian Fainelli
2011-05-13 19:25 ` Manuel Lauss
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).