summaryrefslogtreecommitdiffstats
path: root/drivers/char/watchdog
diff options
context:
space:
mode:
authorWim Van Sebroeck <wim@iguana.be>2007-07-03 19:59:04 +0200
committerWim Van Sebroeck <wim@iguana.be>2007-07-05 07:37:29 +0200
commite75e657756554676f13070266bedbd75d404a0f8 (patch)
treee7ae23553be788b00dc59c89a0b8dec22fe0d94b /drivers/char/watchdog
parent[WATCHDOG] at32ap700x_wdt.c - Add nowayout + MAGICCLOSE features (diff)
downloadlinux-e75e657756554676f13070266bedbd75d404a0f8.tar.xz
linux-e75e657756554676f13070266bedbd75d404a0f8.zip
[WATCHDOG] at32ap700x_wdt.c - Add spinlock support
Add spinlock support so that forked children can't do different io stuff at the same time. Signed-off-by: Hans-Christian Egtvedt <hcegtvedt@atmel.com> Cc: Haavard Skinnemoen <hskinnemoen@atmel.com> Signed-off-by: Wim Van Sebroeck <wim@iguana.be> Cc: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'drivers/char/watchdog')
-rw-r--r--drivers/char/watchdog/at32ap700x_wdt.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/drivers/char/watchdog/at32ap700x_wdt.c b/drivers/char/watchdog/at32ap700x_wdt.c
index fcd55c600b87..75e852e954e7 100644
--- a/drivers/char/watchdog/at32ap700x_wdt.c
+++ b/drivers/char/watchdog/at32ap700x_wdt.c
@@ -18,6 +18,7 @@
#include <linux/watchdog.h>
#include <linux/uaccess.h>
#include <linux/io.h>
+#include <linux/spinlock.h>
#define TIMEOUT_MIN 1
#define TIMEOUT_MAX 2
@@ -53,6 +54,7 @@ MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default="
struct wdt_at32ap700x {
void __iomem *regs;
+ spinlock_t io_lock;
int timeout;
int users;
struct miscdevice miscdev;
@@ -66,9 +68,11 @@ static char expect_release;
*/
static inline void at32_wdt_stop(void)
{
+ spin_lock(&wdt->io_lock);
unsigned long psel = wdt_readl(wdt, CTRL) & WDT_BF(CTRL_PSEL, 0x0f);
wdt_writel(wdt, CTRL, psel | WDT_BF(CTRL_KEY, 0x55));
wdt_writel(wdt, CTRL, psel | WDT_BF(CTRL_KEY, 0xaa));
+ spin_unlock(&wdt->io_lock);
}
/*
@@ -79,12 +83,14 @@ static inline void at32_wdt_start(void)
/* 0xf is 2^16 divider = 2 sec, 0xe is 2^15 divider = 1 sec */
unsigned long psel = (wdt->timeout > 1) ? 0xf : 0xe;
+ spin_lock(&wdt->io_lock);
wdt_writel(wdt, CTRL, WDT_BIT(CTRL_EN)
| WDT_BF(CTRL_PSEL, psel)
| WDT_BF(CTRL_KEY, 0x55));
wdt_writel(wdt, CTRL, WDT_BIT(CTRL_EN)
| WDT_BF(CTRL_PSEL, psel)
| WDT_BF(CTRL_KEY, 0xaa));
+ spin_unlock(&wdt->io_lock);
}
/*
@@ -92,7 +98,9 @@ static inline void at32_wdt_start(void)
*/
static inline void at32_wdt_pat(void)
{
+ spin_lock(&wdt->io_lock);
wdt_writel(wdt, CLR, 0x42);
+ spin_unlock(&wdt->io_lock);
}
/*
@@ -272,6 +280,7 @@ static int __init at32_wdt_probe(struct platform_device *pdev)
dev_dbg(&pdev->dev, "could not map I/O memory\n");
goto err_free;
}
+ spin_lock_init(&wdt->io_lock);
wdt->users = 0;
wdt->miscdev.minor = WATCHDOG_MINOR;
wdt->miscdev.name = "watchdog";