diff options
Diffstat (limited to 'drivers/watchdog/mpc8xx_wdt.c')
-rw-r--r-- | drivers/watchdog/mpc8xx_wdt.c | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/drivers/watchdog/mpc8xx_wdt.c b/drivers/watchdog/mpc8xx_wdt.c index 85b5734403a5..1336425acf20 100644 --- a/drivers/watchdog/mpc8xx_wdt.c +++ b/drivers/watchdog/mpc8xx_wdt.c | |||
@@ -16,36 +16,35 @@ | |||
16 | #include <linux/module.h> | 16 | #include <linux/module.h> |
17 | #include <linux/watchdog.h> | 17 | #include <linux/watchdog.h> |
18 | #include <asm/8xx_immap.h> | 18 | #include <asm/8xx_immap.h> |
19 | #include <asm/uaccess.h> | 19 | #include <linux/uaccess.h> |
20 | #include <asm/io.h> | 20 | #include <linux/io.h> |
21 | #include <syslib/m8xx_wdt.h> | 21 | #include <syslib/m8xx_wdt.h> |
22 | 22 | ||
23 | static unsigned long wdt_opened; | 23 | static unsigned long wdt_opened; |
24 | static int wdt_status; | 24 | static int wdt_status; |
25 | static spinlock_t wdt_lock; | ||
25 | 26 | ||
26 | static void mpc8xx_wdt_handler_disable(void) | 27 | static void mpc8xx_wdt_handler_disable(void) |
27 | { | 28 | { |
28 | volatile uint __iomem *piscr; | 29 | volatile uint __iomem *piscr; |
29 | piscr = (uint *)&((immap_t*)IMAP_ADDR)->im_sit.sit_piscr; | 30 | piscr = (uint *)&((immap_t *)IMAP_ADDR)->im_sit.sit_piscr; |
30 | 31 | ||
31 | if (!m8xx_has_internal_rtc) | 32 | if (!m8xx_has_internal_rtc) |
32 | m8xx_wdt_stop_timer(); | 33 | m8xx_wdt_stop_timer(); |
33 | else | 34 | else |
34 | out_be32(piscr, in_be32(piscr) & ~(PISCR_PIE | PISCR_PTE)); | 35 | out_be32(piscr, in_be32(piscr) & ~(PISCR_PIE | PISCR_PTE)); |
35 | |||
36 | printk(KERN_NOTICE "mpc8xx_wdt: keep-alive handler deactivated\n"); | 36 | printk(KERN_NOTICE "mpc8xx_wdt: keep-alive handler deactivated\n"); |
37 | } | 37 | } |
38 | 38 | ||
39 | static void mpc8xx_wdt_handler_enable(void) | 39 | static void mpc8xx_wdt_handler_enable(void) |
40 | { | 40 | { |
41 | volatile uint __iomem *piscr; | 41 | volatile uint __iomem *piscr; |
42 | piscr = (uint *)&((immap_t*)IMAP_ADDR)->im_sit.sit_piscr; | 42 | piscr = (uint *)&((immap_t *)IMAP_ADDR)->im_sit.sit_piscr; |
43 | 43 | ||
44 | if (!m8xx_has_internal_rtc) | 44 | if (!m8xx_has_internal_rtc) |
45 | m8xx_wdt_install_timer(); | 45 | m8xx_wdt_install_timer(); |
46 | else | 46 | else |
47 | out_be32(piscr, in_be32(piscr) | PISCR_PIE | PISCR_PTE); | 47 | out_be32(piscr, in_be32(piscr) | PISCR_PIE | PISCR_PTE); |
48 | |||
49 | printk(KERN_NOTICE "mpc8xx_wdt: keep-alive handler activated\n"); | 48 | printk(KERN_NOTICE "mpc8xx_wdt: keep-alive handler activated\n"); |
50 | } | 49 | } |
51 | 50 | ||
@@ -53,37 +52,34 @@ static int mpc8xx_wdt_open(struct inode *inode, struct file *file) | |||
53 | { | 52 | { |
54 | if (test_and_set_bit(0, &wdt_opened)) | 53 | if (test_and_set_bit(0, &wdt_opened)) |
55 | return -EBUSY; | 54 | return -EBUSY; |
56 | |||
57 | m8xx_wdt_reset(); | 55 | m8xx_wdt_reset(); |
58 | mpc8xx_wdt_handler_disable(); | 56 | mpc8xx_wdt_handler_disable(); |
59 | |||
60 | return nonseekable_open(inode, file); | 57 | return nonseekable_open(inode, file); |
61 | } | 58 | } |
62 | 59 | ||
63 | static int mpc8xx_wdt_release(struct inode *inode, struct file *file) | 60 | static int mpc8xx_wdt_release(struct inode *inode, struct file *file) |
64 | { | 61 | { |
65 | m8xx_wdt_reset(); | 62 | m8xx_wdt_reset(); |
66 | |||
67 | #if !defined(CONFIG_WATCHDOG_NOWAYOUT) | 63 | #if !defined(CONFIG_WATCHDOG_NOWAYOUT) |
68 | mpc8xx_wdt_handler_enable(); | 64 | mpc8xx_wdt_handler_enable(); |
69 | #endif | 65 | #endif |
70 | |||
71 | clear_bit(0, &wdt_opened); | 66 | clear_bit(0, &wdt_opened); |
72 | |||
73 | return 0; | 67 | return 0; |
74 | } | 68 | } |
75 | 69 | ||
76 | static ssize_t mpc8xx_wdt_write(struct file *file, const char *data, size_t len, | 70 | static ssize_t mpc8xx_wdt_write(struct file *file, const char *data, |
77 | loff_t * ppos) | 71 | size_t len, loff_t *ppos) |
78 | { | 72 | { |
79 | if (len) | 73 | if (len) { |
74 | spin_lock(&wdt_lock); | ||
80 | m8xx_wdt_reset(); | 75 | m8xx_wdt_reset(); |
81 | 76 | spin_unlock(&wdt_lock); | |
77 | } | ||
82 | return len; | 78 | return len; |
83 | } | 79 | } |
84 | 80 | ||
85 | static int mpc8xx_wdt_ioctl(struct inode *inode, struct file *file, | 81 | static long mpc8xx_wdt_ioctl(struct file *file, |
86 | unsigned int cmd, unsigned long arg) | 82 | unsigned int cmd, unsigned long arg) |
87 | { | 83 | { |
88 | int timeout; | 84 | int timeout; |
89 | static struct watchdog_info info = { | 85 | static struct watchdog_info info = { |
@@ -112,15 +108,19 @@ static int mpc8xx_wdt_ioctl(struct inode *inode, struct file *file, | |||
112 | return -EOPNOTSUPP; | 108 | return -EOPNOTSUPP; |
113 | 109 | ||
114 | case WDIOC_KEEPALIVE: | 110 | case WDIOC_KEEPALIVE: |
111 | spin_lock(&wdt_lock); | ||
115 | m8xx_wdt_reset(); | 112 | m8xx_wdt_reset(); |
116 | wdt_status |= WDIOF_KEEPALIVEPING; | 113 | wdt_status |= WDIOF_KEEPALIVEPING; |
114 | spin_unlock(&wdt_lock); | ||
117 | break; | 115 | break; |
118 | 116 | ||
119 | case WDIOC_SETTIMEOUT: | 117 | case WDIOC_SETTIMEOUT: |
120 | return -EOPNOTSUPP; | 118 | return -EOPNOTSUPP; |
121 | 119 | ||
122 | case WDIOC_GETTIMEOUT: | 120 | case WDIOC_GETTIMEOUT: |
121 | spin_lock(&wdt_lock); | ||
123 | timeout = m8xx_wdt_get_timeout(); | 122 | timeout = m8xx_wdt_get_timeout(); |
123 | spin_unlock(&wdt_lock); | ||
124 | if (put_user(timeout, (int *)arg)) | 124 | if (put_user(timeout, (int *)arg)) |
125 | return -EFAULT; | 125 | return -EFAULT; |
126 | break; | 126 | break; |
@@ -136,7 +136,7 @@ static const struct file_operations mpc8xx_wdt_fops = { | |||
136 | .owner = THIS_MODULE, | 136 | .owner = THIS_MODULE, |
137 | .llseek = no_llseek, | 137 | .llseek = no_llseek, |
138 | .write = mpc8xx_wdt_write, | 138 | .write = mpc8xx_wdt_write, |
139 | .ioctl = mpc8xx_wdt_ioctl, | 139 | .unlocked_ioctl = mpc8xx_wdt_ioctl, |
140 | .open = mpc8xx_wdt_open, | 140 | .open = mpc8xx_wdt_open, |
141 | .release = mpc8xx_wdt_release, | 141 | .release = mpc8xx_wdt_release, |
142 | }; | 142 | }; |
@@ -149,6 +149,7 @@ static struct miscdevice mpc8xx_wdt_miscdev = { | |||
149 | 149 | ||
150 | static int __init mpc8xx_wdt_init(void) | 150 | static int __init mpc8xx_wdt_init(void) |
151 | { | 151 | { |
152 | spin_lock_init(&wdt_lock); | ||
152 | return misc_register(&mpc8xx_wdt_miscdev); | 153 | return misc_register(&mpc8xx_wdt_miscdev); |
153 | } | 154 | } |
154 | 155 | ||