summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
2840114)
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>
#include <linux/watchdog.h>
#include <linux/uaccess.h>
#include <linux/io.h>
#include <linux/watchdog.h>
#include <linux/uaccess.h>
#include <linux/io.h>
+#include <linux/spinlock.h>
#define TIMEOUT_MIN 1
#define TIMEOUT_MAX 2
#define TIMEOUT_MIN 1
#define TIMEOUT_MAX 2
struct wdt_at32ap700x {
void __iomem *regs;
struct wdt_at32ap700x {
void __iomem *regs;
int timeout;
int users;
struct miscdevice miscdev;
int timeout;
int users;
struct miscdevice miscdev;
*/
static inline void at32_wdt_stop(void)
{
*/
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));
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);
/* 0xf is 2^16 divider = 2 sec, 0xe is 2^15 divider = 1 sec */
unsigned long psel = (wdt->timeout > 1) ? 0xf : 0xe;
/* 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));
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);
*/
static inline void at32_wdt_pat(void)
{
*/
static inline void at32_wdt_pat(void)
{
+ spin_lock(&wdt->io_lock);
wdt_writel(wdt, CLR, 0x42);
wdt_writel(wdt, CLR, 0x42);
+ spin_unlock(&wdt->io_lock);
dev_dbg(&pdev->dev, "could not map I/O memory\n");
goto err_free;
}
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";
wdt->users = 0;
wdt->miscdev.minor = WATCHDOG_MINOR;
wdt->miscdev.name = "watchdog";