Commit 20d35f3e authored by Alan Cox's avatar Alan Cox Committed by Wim Van Sebroeck

[WATCHDOG 22/57] ixp4xx_wdt: unlocked_ioctl

Review and switch to unlocked_ioctl
Signed-off-by: default avatarAlan Cox <alan@redhat.com>
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 640b4f68
...@@ -30,40 +30,40 @@ static int nowayout = WATCHDOG_NOWAYOUT; ...@@ -30,40 +30,40 @@ static int nowayout = WATCHDOG_NOWAYOUT;
static int heartbeat = 60; /* (secs) Default is 1 minute */ static int heartbeat = 60; /* (secs) Default is 1 minute */
static unsigned long wdt_status; static unsigned long wdt_status;
static unsigned long boot_status; static unsigned long boot_status;
static spin_lock_t wdt_lock;
#define WDT_TICK_RATE (IXP4XX_PERIPHERAL_BUS_CLOCK * 1000000UL) #define WDT_TICK_RATE (IXP4XX_PERIPHERAL_BUS_CLOCK * 1000000UL)
#define WDT_IN_USE 0 #define WDT_IN_USE 0
#define WDT_OK_TO_CLOSE 1 #define WDT_OK_TO_CLOSE 1
static void static void wdt_enable(void)
wdt_enable(void)
{ {
spin_lock(&wdt_lock);
*IXP4XX_OSWK = IXP4XX_WDT_KEY; *IXP4XX_OSWK = IXP4XX_WDT_KEY;
*IXP4XX_OSWE = 0; *IXP4XX_OSWE = 0;
*IXP4XX_OSWT = WDT_TICK_RATE * heartbeat; *IXP4XX_OSWT = WDT_TICK_RATE * heartbeat;
*IXP4XX_OSWE = IXP4XX_WDT_COUNT_ENABLE | IXP4XX_WDT_RESET_ENABLE; *IXP4XX_OSWE = IXP4XX_WDT_COUNT_ENABLE | IXP4XX_WDT_RESET_ENABLE;
*IXP4XX_OSWK = 0; *IXP4XX_OSWK = 0;
spin_unlock(&wdt_lock);
} }
static void static void wdt_disable(void)
wdt_disable(void)
{ {
spin_lock(&wdt_lock);
*IXP4XX_OSWK = IXP4XX_WDT_KEY; *IXP4XX_OSWK = IXP4XX_WDT_KEY;
*IXP4XX_OSWE = 0; *IXP4XX_OSWE = 0;
*IXP4XX_OSWK = 0; *IXP4XX_OSWK = 0;
spin_unlock(&wdt_lock);
} }
static int static int ixp4xx_wdt_open(struct inode *inode, struct file *file)
ixp4xx_wdt_open(struct inode *inode, struct file *file)
{ {
if (test_and_set_bit(WDT_IN_USE, &wdt_status)) if (test_and_set_bit(WDT_IN_USE, &wdt_status))
return -EBUSY; return -EBUSY;
clear_bit(WDT_OK_TO_CLOSE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
wdt_enable(); wdt_enable();
return nonseekable_open(inode, file); return nonseekable_open(inode, file);
} }
...@@ -87,7 +87,6 @@ ixp4xx_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos) ...@@ -87,7 +87,6 @@ ixp4xx_wdt_write(struct file *file, const char *data, size_t len, loff_t *ppos)
} }
wdt_enable(); wdt_enable();
} }
return len; return len;
} }
...@@ -98,8 +97,7 @@ static struct watchdog_info ident = { ...@@ -98,8 +97,7 @@ static struct watchdog_info ident = {
}; };
static int static long ixp4xx_wdt_ioctl(struct file *file, unsigned int cmd,
ixp4xx_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
unsigned long arg) unsigned long arg)
{ {
int ret = -ENOTTY; int ret = -ENOTTY;
...@@ -145,16 +143,13 @@ ixp4xx_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd, ...@@ -145,16 +143,13 @@ ixp4xx_wdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
return ret; return ret;
} }
static int static int ixp4xx_wdt_release(struct inode *inode, struct file *file)
ixp4xx_wdt_release(struct inode *inode, struct file *file)
{ {
if (test_bit(WDT_OK_TO_CLOSE, &wdt_status)) { if (test_bit(WDT_OK_TO_CLOSE, &wdt_status))
wdt_disable(); wdt_disable();
} else { else
printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - " printk(KERN_CRIT "WATCHDOG: Device closed unexpectedly - "
"timer will not stop\n"); "timer will not stop\n");
}
clear_bit(WDT_IN_USE, &wdt_status); clear_bit(WDT_IN_USE, &wdt_status);
clear_bit(WDT_OK_TO_CLOSE, &wdt_status); clear_bit(WDT_OK_TO_CLOSE, &wdt_status);
...@@ -167,7 +162,7 @@ static const struct file_operations ixp4xx_wdt_fops = ...@@ -167,7 +162,7 @@ static const struct file_operations ixp4xx_wdt_fops =
.owner = THIS_MODULE, .owner = THIS_MODULE,
.llseek = no_llseek, .llseek = no_llseek,
.write = ixp4xx_wdt_write, .write = ixp4xx_wdt_write,
.ioctl = ixp4xx_wdt_ioctl, .unlocked_ioctl = ixp4xx_wdt_ioctl,
.open = ixp4xx_wdt_open, .open = ixp4xx_wdt_open,
.release = ixp4xx_wdt_release, .release = ixp4xx_wdt_release,
}; };
...@@ -191,14 +186,12 @@ static int __init ixp4xx_wdt_init(void) ...@@ -191,14 +186,12 @@ static int __init ixp4xx_wdt_init(void)
return -ENODEV; return -ENODEV;
} }
spin_lock_init(&wdt_lock);
boot_status = (*IXP4XX_OSST & IXP4XX_OSST_TIMER_WARM_RESET) ?
WDIOF_CARDRESET : 0;
ret = misc_register(&ixp4xx_wdt_miscdev); ret = misc_register(&ixp4xx_wdt_miscdev);
if (ret == 0) if (ret == 0)
printk("IXP4xx Watchdog Timer: heartbeat %d sec\n", heartbeat); printk("IXP4xx Watchdog Timer: heartbeat %d sec\n", heartbeat);
boot_status = (*IXP4XX_OSST & IXP4XX_OSST_TIMER_WARM_RESET) ?
WDIOF_CARDRESET : 0;
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment