diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2007-01-11 16:35:40 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2007-01-11 16:35:40 -0500 |
commit | c2bd11c7cbba45c3a1d850a8a29855cb4d61654c (patch) | |
tree | 65f9d5830fd216abc65bc3d8cf09870139dca315 /drivers/char/watchdog | |
parent | 0349a363e23a0533e081ca320c837bc08247343e (diff) |
[WATCHDOG] advantechwdt.c - convert to platform_device
Convert the advantechwdt watchdog into a platform_device
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/char/watchdog')
-rw-r--r-- | drivers/char/watchdog/advantechwdt.c | 55 |
1 files changed, 49 insertions, 6 deletions
diff --git a/drivers/char/watchdog/advantechwdt.c b/drivers/char/watchdog/advantechwdt.c index 216af0d67fd2..528a417856c4 100644 --- a/drivers/char/watchdog/advantechwdt.c +++ b/drivers/char/watchdog/advantechwdt.c | |||
@@ -37,6 +37,7 @@ | |||
37 | #include <linux/ioport.h> | 37 | #include <linux/ioport.h> |
38 | #include <linux/notifier.h> | 38 | #include <linux/notifier.h> |
39 | #include <linux/reboot.h> | 39 | #include <linux/reboot.h> |
40 | #include <linux/platform_device.h> | ||
40 | #include <linux/init.h> | 41 | #include <linux/init.h> |
41 | 42 | ||
42 | #include <asm/io.h> | 43 | #include <asm/io.h> |
@@ -48,6 +49,7 @@ | |||
48 | #define WATCHDOG_NAME "Advantech WDT" | 49 | #define WATCHDOG_NAME "Advantech WDT" |
49 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ | 50 | #define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */ |
50 | 51 | ||
52 | static struct platform_device *advwdt_platform_device; /* the watchdog platform device */ | ||
51 | static unsigned long advwdt_is_open; | 53 | static unsigned long advwdt_is_open; |
52 | static char adv_expect_close; | 54 | static char adv_expect_close; |
53 | 55 | ||
@@ -269,13 +271,11 @@ static struct notifier_block advwdt_notifier = { | |||
269 | * Init & exit routines | 271 | * Init & exit routines |
270 | */ | 272 | */ |
271 | 273 | ||
272 | static int __init | 274 | static int __devinit |
273 | advwdt_init(void) | 275 | advwdt_probe(struct platform_device *dev) |
274 | { | 276 | { |
275 | int ret; | 277 | int ret; |
276 | 278 | ||
277 | printk(KERN_INFO "WDT driver for Advantech single board computer initialising.\n"); | ||
278 | |||
279 | if (wdt_stop != wdt_start) { | 279 | if (wdt_stop != wdt_start) { |
280 | if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { | 280 | if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { |
281 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", | 281 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", |
@@ -328,14 +328,57 @@ unreg_stop: | |||
328 | goto out; | 328 | goto out; |
329 | } | 329 | } |
330 | 330 | ||
331 | static void __exit | 331 | static int __devexit |
332 | advwdt_exit(void) | 332 | advwdt_remove(struct platform_device *dev) |
333 | { | 333 | { |
334 | misc_deregister(&advwdt_miscdev); | 334 | misc_deregister(&advwdt_miscdev); |
335 | unregister_reboot_notifier(&advwdt_notifier); | 335 | unregister_reboot_notifier(&advwdt_notifier); |
336 | release_region(wdt_start,1); | 336 | release_region(wdt_start,1); |
337 | if(wdt_stop != wdt_start) | 337 | if(wdt_stop != wdt_start) |
338 | release_region(wdt_stop,1); | 338 | release_region(wdt_stop,1); |
339 | |||
340 | return 0; | ||
341 | } | ||
342 | |||
343 | static struct platform_driver advwdt_driver = { | ||
344 | .probe = advwdt_probe, | ||
345 | .remove = __devexit_p(advwdt_remove), | ||
346 | .driver = { | ||
347 | .owner = THIS_MODULE, | ||
348 | .name = DRV_NAME, | ||
349 | }, | ||
350 | }; | ||
351 | |||
352 | static int __init | ||
353 | advwdt_init(void) | ||
354 | { | ||
355 | int err; | ||
356 | |||
357 | printk(KERN_INFO "WDT driver for Advantech single board computer initialising.\n"); | ||
358 | |||
359 | err = platform_driver_register(&advwdt_driver); | ||
360 | if (err) | ||
361 | return err; | ||
362 | |||
363 | advwdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0); | ||
364 | if (IS_ERR(advwdt_platform_device)) { | ||
365 | err = PTR_ERR(advwdt_platform_device); | ||
366 | goto unreg_platform_driver; | ||
367 | } | ||
368 | |||
369 | return 0; | ||
370 | |||
371 | unreg_platform_driver: | ||
372 | platform_driver_unregister(&advwdt_driver); | ||
373 | return err; | ||
374 | } | ||
375 | |||
376 | static void __exit | ||
377 | advwdt_exit(void) | ||
378 | { | ||
379 | platform_device_unregister(advwdt_platform_device); | ||
380 | platform_driver_unregister(&advwdt_driver); | ||
381 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | ||
339 | } | 382 | } |
340 | 383 | ||
341 | module_init(advwdt_init); | 384 | module_init(advwdt_init); |