diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2010-10-23 16:59:42 -0400 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2010-12-02 09:10:16 -0500 |
commit | e6c3b699b2f6fcba7036c079b6f16bf9556c7f0d (patch) | |
tree | eabd7b6acce4c6b9806d7176e22e271345ed9c2c /drivers/watchdog/bcm63xx_wdt.c | |
parent | c54fb811745967732bc9e31d837e0c9925e12b4b (diff) |
watchdog: bcm63xx_wdt: improve platform part.
* fix devinit and devexit sections
* fix platform removal code so that the iounmap happens after the removal of the timer.
* changes the reboot_notifier by a platform shutdown method.
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/watchdog/bcm63xx_wdt.c')
-rw-r--r-- | drivers/watchdog/bcm63xx_wdt.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/drivers/watchdog/bcm63xx_wdt.c b/drivers/watchdog/bcm63xx_wdt.c index a1debc89356b..3c5045a206dd 100644 --- a/drivers/watchdog/bcm63xx_wdt.c +++ b/drivers/watchdog/bcm63xx_wdt.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include <linux/miscdevice.h> | 18 | #include <linux/miscdevice.h> |
19 | #include <linux/module.h> | 19 | #include <linux/module.h> |
20 | #include <linux/moduleparam.h> | 20 | #include <linux/moduleparam.h> |
21 | #include <linux/reboot.h> | ||
22 | #include <linux/types.h> | 21 | #include <linux/types.h> |
23 | #include <linux/uaccess.h> | 22 | #include <linux/uaccess.h> |
24 | #include <linux/watchdog.h> | 23 | #include <linux/watchdog.h> |
@@ -220,14 +219,6 @@ static long bcm63xx_wdt_ioctl(struct file *file, unsigned int cmd, | |||
220 | } | 219 | } |
221 | } | 220 | } |
222 | 221 | ||
223 | static int bcm63xx_wdt_notify_sys(struct notifier_block *this, | ||
224 | unsigned long code, void *unused) | ||
225 | { | ||
226 | if (code == SYS_DOWN || code == SYS_HALT) | ||
227 | bcm63xx_wdt_pause(); | ||
228 | return NOTIFY_DONE; | ||
229 | } | ||
230 | |||
231 | static const struct file_operations bcm63xx_wdt_fops = { | 222 | static const struct file_operations bcm63xx_wdt_fops = { |
232 | .owner = THIS_MODULE, | 223 | .owner = THIS_MODULE, |
233 | .llseek = no_llseek, | 224 | .llseek = no_llseek, |
@@ -243,12 +234,8 @@ static struct miscdevice bcm63xx_wdt_miscdev = { | |||
243 | .fops = &bcm63xx_wdt_fops, | 234 | .fops = &bcm63xx_wdt_fops, |
244 | }; | 235 | }; |
245 | 236 | ||
246 | static struct notifier_block bcm63xx_wdt_notifier = { | ||
247 | .notifier_call = bcm63xx_wdt_notify_sys, | ||
248 | }; | ||
249 | 237 | ||
250 | 238 | static int __devinit bcm63xx_wdt_probe(struct platform_device *pdev) | |
251 | static int bcm63xx_wdt_probe(struct platform_device *pdev) | ||
252 | { | 239 | { |
253 | int ret; | 240 | int ret; |
254 | struct resource *r; | 241 | struct resource *r; |
@@ -280,16 +267,10 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev) | |||
280 | wdt_time); | 267 | wdt_time); |
281 | } | 268 | } |
282 | 269 | ||
283 | ret = register_reboot_notifier(&bcm63xx_wdt_notifier); | ||
284 | if (ret) { | ||
285 | dev_err(&pdev->dev, "failed to register reboot_notifier\n"); | ||
286 | goto unregister_timer; | ||
287 | } | ||
288 | |||
289 | ret = misc_register(&bcm63xx_wdt_miscdev); | 270 | ret = misc_register(&bcm63xx_wdt_miscdev); |
290 | if (ret < 0) { | 271 | if (ret < 0) { |
291 | dev_err(&pdev->dev, "failed to register watchdog device\n"); | 272 | dev_err(&pdev->dev, "failed to register watchdog device\n"); |
292 | goto unregister_reboot_notifier; | 273 | goto unregister_timer; |
293 | } | 274 | } |
294 | 275 | ||
295 | dev_info(&pdev->dev, " started, timer margin: %d sec\n", | 276 | dev_info(&pdev->dev, " started, timer margin: %d sec\n", |
@@ -297,8 +278,6 @@ static int bcm63xx_wdt_probe(struct platform_device *pdev) | |||
297 | 278 | ||
298 | return 0; | 279 | return 0; |
299 | 280 | ||
300 | unregister_reboot_notifier: | ||
301 | unregister_reboot_notifier(&bcm63xx_wdt_notifier); | ||
302 | unregister_timer: | 281 | unregister_timer: |
303 | bcm63xx_timer_unregister(TIMER_WDT_ID); | 282 | bcm63xx_timer_unregister(TIMER_WDT_ID); |
304 | unmap: | 283 | unmap: |
@@ -306,25 +285,28 @@ unmap: | |||
306 | return ret; | 285 | return ret; |
307 | } | 286 | } |
308 | 287 | ||
309 | static int bcm63xx_wdt_remove(struct platform_device *pdev) | 288 | static int __devexit bcm63xx_wdt_remove(struct platform_device *pdev) |
310 | { | 289 | { |
311 | if (!nowayout) | 290 | if (!nowayout) |
312 | bcm63xx_wdt_pause(); | 291 | bcm63xx_wdt_pause(); |
313 | 292 | ||
314 | misc_deregister(&bcm63xx_wdt_miscdev); | 293 | misc_deregister(&bcm63xx_wdt_miscdev); |
315 | |||
316 | iounmap(bcm63xx_wdt_device.regs); | ||
317 | |||
318 | unregister_reboot_notifier(&bcm63xx_wdt_notifier); | ||
319 | bcm63xx_timer_unregister(TIMER_WDT_ID); | 294 | bcm63xx_timer_unregister(TIMER_WDT_ID); |
320 | 295 | iounmap(bcm63xx_wdt_device.regs); | |
321 | return 0; | 296 | return 0; |
322 | } | 297 | } |
323 | 298 | ||
299 | static void bcm63xx_wdt_shutdown(struct platform_device *pdev) | ||
300 | { | ||
301 | bcm63xx_wdt_pause(); | ||
302 | } | ||
303 | |||
324 | static struct platform_driver bcm63xx_wdt = { | 304 | static struct platform_driver bcm63xx_wdt = { |
325 | .probe = bcm63xx_wdt_probe, | 305 | .probe = bcm63xx_wdt_probe, |
326 | .remove = bcm63xx_wdt_remove, | 306 | .remove = __devexit_p(bcm63xx_wdt_remove), |
307 | .shutdown = bcm63xx_wdt_shutdown, | ||
327 | .driver = { | 308 | .driver = { |
309 | .owner = THIS_MODULE, | ||
328 | .name = "bcm63xx-wdt", | 310 | .name = "bcm63xx-wdt", |
329 | } | 311 | } |
330 | }; | 312 | }; |