Watchdog: mtx-1: fix abuse of gpio registers
PATCH 1/1 Watchdog: mtx-1: fix abuse of gpio registers
This patch replaces the drivers racy abuse of the gpio2 direction register with calls to the gpio library.
--- drivers/watchdog/mtx-1_wdt.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)
drivers/watchdog/mtx-1_wdt.c +10 -7
@@ -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;
Signature · 1 line
1.7.5.rc3
Hello Manuel,
Quoted 5 lines · 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 <[email protected]>Signed-off-by Manuel Lauss <[email protected]>
I will give a try at this patch, it looks good at first glance.
Quoted 53 lines
--- drivers/watchdog/mtx-1_wdt.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-)drivers/watchdog/mtx-1_wdt.c +10
-7@@ -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;
Quoted 8 lines · Manuel Lauss
This patch replaces the drivers racy abuse of the gpio2 direction register with calls to the gpio library.
Cc Florian Fainelli <[email protected]>Signed-off-by Manuel Lauss <[email protected]>---
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html