diff options
Diffstat (limited to 'drivers/watchdog/booke_wdt.c')
-rw-r--r-- | drivers/watchdog/booke_wdt.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/watchdog/booke_wdt.c b/drivers/watchdog/booke_wdt.c index d11ffb091b0d..636e013e221e 100644 --- a/drivers/watchdog/booke_wdt.c +++ b/drivers/watchdog/booke_wdt.c | |||
@@ -193,8 +193,15 @@ static long booke_wdt_ioctl(struct file *file, | |||
193 | return 0; | 193 | return 0; |
194 | } | 194 | } |
195 | 195 | ||
196 | /* wdt_is_active stores wether or not the /dev/watchdog device is opened */ | ||
197 | static unsigned long wdt_is_active; | ||
198 | |||
196 | static int booke_wdt_open(struct inode *inode, struct file *file) | 199 | static int booke_wdt_open(struct inode *inode, struct file *file) |
197 | { | 200 | { |
201 | /* /dev/watchdog can only be opened once */ | ||
202 | if (test_and_set_bit(0, &wdt_is_active)) | ||
203 | return -EBUSY; | ||
204 | |||
198 | spin_lock(&booke_wdt_lock); | 205 | spin_lock(&booke_wdt_lock); |
199 | if (booke_wdt_enabled == 0) { | 206 | if (booke_wdt_enabled == 0) { |
200 | booke_wdt_enabled = 1; | 207 | booke_wdt_enabled = 1; |
@@ -210,8 +217,17 @@ static int booke_wdt_open(struct inode *inode, struct file *file) | |||
210 | 217 | ||
211 | static int booke_wdt_release(struct inode *inode, struct file *file) | 218 | static int booke_wdt_release(struct inode *inode, struct file *file) |
212 | { | 219 | { |
220 | #ifndef CONFIG_WATCHDOG_NOWAYOUT | ||
221 | /* Normally, the watchdog is disabled when /dev/watchdog is closed, but | ||
222 | * if CONFIG_WATCHDOG_NOWAYOUT is defined, then it means that the | ||
223 | * watchdog should remain enabled. So we disable it only if | ||
224 | * CONFIG_WATCHDOG_NOWAYOUT is not defined. | ||
225 | */ | ||
213 | on_each_cpu(__booke_wdt_disable, NULL, 0); | 226 | on_each_cpu(__booke_wdt_disable, NULL, 0); |
214 | booke_wdt_enabled = 0; | 227 | booke_wdt_enabled = 0; |
228 | #endif | ||
229 | |||
230 | clear_bit(0, &wdt_is_active); | ||
215 | 231 | ||
216 | return 0; | 232 | return 0; |
217 | } | 233 | } |