From: Wim Van Sebroeck Date: Sun, 10 Sep 2006 10:48:15 +0000 (+0200) Subject: [WATCHDOG] pnx4008_wdt.c - spinlock fixes. X-Git-Tag: v2.6.19-rc1~370^2~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=99d2853ac953900962d8191788060e80766eb214;p=platform%2Fkernel%2Flinux-exynos.git [WATCHDOG] pnx4008_wdt.c - spinlock fixes. Add io spinlocks to prevent possible race conditions between start and stop operations that are issued from different child processes where the master process opened /dev/watchdog. Signed-off-by: Wim Van Sebroeck --- diff --git a/drivers/char/watchdog/pnx4008_wdt.c b/drivers/char/watchdog/pnx4008_wdt.c index 465dfd3..359168e 100644 --- a/drivers/char/watchdog/pnx4008_wdt.c +++ b/drivers/char/watchdog/pnx4008_wdt.c @@ -28,6 +28,7 @@ #include #include #include +#include #include #include @@ -80,6 +81,7 @@ static int nowayout = WATCHDOG_NOWAYOUT; static int heartbeat = DEFAULT_HEARTBEAT; +static spinlock_t io_lock; static unsigned long wdt_status; #define WDT_IN_USE 0 #define WDT_OK_TO_CLOSE 1 @@ -94,6 +96,8 @@ struct clk *wdt_clk; static void wdt_enable(void) { + spin_lock(&io_lock); + if (wdt_clk) clk_set_rate(wdt_clk, 1); @@ -113,13 +117,19 @@ static void wdt_enable(void) __raw_writel(heartbeat * WDOG_COUNTER_RATE, WDTIM_MATCH0(wdt_base)); /*enable counter, stop when debugger active */ __raw_writel(COUNT_ENAB | DEBUG_EN, WDTIM_CTRL(wdt_base)); + + spin_unlock(&io_lock); } static void wdt_disable(void) { + spin_lock(&io_lock); + __raw_writel(0, WDTIM_CTRL(wdt_base)); /*stop counter */ if (wdt_clk) clk_set_rate(wdt_clk, 0); + + spin_unlock(&io_lock); } static int pnx4008_wdt_open(struct inode *inode, struct file *file) @@ -248,6 +258,8 @@ static int pnx4008_wdt_probe(struct platform_device *pdev) int ret = 0, size; struct resource *res; + spin_lock_init(&io_lock); + if (heartbeat < 1 || heartbeat > MAX_HEARTBEAT) heartbeat = DEFAULT_HEARTBEAT;