diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2007-01-27 16:39:46 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2007-01-27 16:39:46 -0500 |
commit | 745ac1ea6e06125cc1326adbec34d756b25678c6 (patch) | |
tree | ae4f65de9ca556f983752a42d3322bdf30741e0e /drivers/char/watchdog/ib700wdt.c | |
parent | e42162a46d948769c8b45d25ee81827bc7dac435 (diff) |
[WATCHDOG] ib700wdt.c - convert to platform_device
Convert the ib700wdt watchdog into a platform_device
Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
Diffstat (limited to 'drivers/char/watchdog/ib700wdt.c')
-rw-r--r-- | drivers/char/watchdog/ib700wdt.c | 53 |
1 files changed, 47 insertions, 6 deletions
diff --git a/drivers/char/watchdog/ib700wdt.c b/drivers/char/watchdog/ib700wdt.c index be61e4755891..b74e15159c02 100644 --- a/drivers/char/watchdog/ib700wdt.c +++ b/drivers/char/watchdog/ib700wdt.c | |||
@@ -42,16 +42,20 @@ | |||
42 | #include <linux/init.h> | 42 | #include <linux/init.h> |
43 | #include <linux/spinlock.h> | 43 | #include <linux/spinlock.h> |
44 | #include <linux/moduleparam.h> | 44 | #include <linux/moduleparam.h> |
45 | #include <linux/platform_device.h> | ||
45 | 46 | ||
46 | #include <asm/io.h> | 47 | #include <asm/io.h> |
47 | #include <asm/uaccess.h> | 48 | #include <asm/uaccess.h> |
48 | #include <asm/system.h> | 49 | #include <asm/system.h> |
49 | 50 | ||
51 | static struct platform_device *ibwdt_platform_device; | ||
50 | static unsigned long ibwdt_is_open; | 52 | static unsigned long ibwdt_is_open; |
51 | static spinlock_t ibwdt_lock; | 53 | static spinlock_t ibwdt_lock; |
52 | static char expect_close; | 54 | static char expect_close; |
53 | 55 | ||
54 | #define PFX "ib700wdt: " | 56 | /* Module information */ |
57 | #define DRV_NAME "ib700wdt" | ||
58 | #define PFX DRV_NAME ": " | ||
55 | 59 | ||
56 | /* | 60 | /* |
57 | * | 61 | * |
@@ -326,12 +330,10 @@ static struct notifier_block ibwdt_notifier = { | |||
326 | * Init & exit routines | 330 | * Init & exit routines |
327 | */ | 331 | */ |
328 | 332 | ||
329 | static int __init ibwdt_init(void) | 333 | static int __devinit ibwdt_probe(struct platform_device *dev) |
330 | { | 334 | { |
331 | int res; | 335 | int res; |
332 | 336 | ||
333 | printk(KERN_INFO PFX "WDT driver for IB700 single board computer initialising.\n"); | ||
334 | |||
335 | spin_lock_init(&ibwdt_lock); | 337 | spin_lock_init(&ibwdt_lock); |
336 | 338 | ||
337 | #if WDT_START != WDT_STOP | 339 | #if WDT_START != WDT_STOP |
@@ -373,8 +375,7 @@ out_nostopreg: | |||
373 | return res; | 375 | return res; |
374 | } | 376 | } |
375 | 377 | ||
376 | static void __exit | 378 | static int __devexit ibwdt_remove(struct platform_device *dev) |
377 | ibwdt_exit(void) | ||
378 | { | 379 | { |
379 | misc_deregister(&ibwdt_miscdev); | 380 | misc_deregister(&ibwdt_miscdev); |
380 | unregister_reboot_notifier(&ibwdt_notifier); | 381 | unregister_reboot_notifier(&ibwdt_notifier); |
@@ -382,6 +383,46 @@ ibwdt_exit(void) | |||
382 | #if WDT_START != WDT_STOP | 383 | #if WDT_START != WDT_STOP |
383 | release_region(WDT_STOP,1); | 384 | release_region(WDT_STOP,1); |
384 | #endif | 385 | #endif |
386 | return 0; | ||
387 | } | ||
388 | |||
389 | static struct platform_driver ibwdt_driver = { | ||
390 | .probe = ibwdt_probe, | ||
391 | .remove = __devexit_p(ibwdt_remove), | ||
392 | .driver = { | ||
393 | .owner = THIS_MODULE, | ||
394 | .name = DRV_NAME, | ||
395 | }, | ||
396 | }; | ||
397 | |||
398 | static int __init ibwdt_init(void) | ||
399 | { | ||
400 | int err; | ||
401 | |||
402 | printk(KERN_INFO PFX "WDT driver for IB700 single board computer initialising.\n"); | ||
403 | |||
404 | err = platform_driver_register(&ibwdt_driver); | ||
405 | if (err) | ||
406 | return err; | ||
407 | |||
408 | ibwdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0); | ||
409 | if (IS_ERR(ibwdt_platform_device)) { | ||
410 | err = PTR_ERR(ibwdt_platform_device); | ||
411 | goto unreg_platform_driver; | ||
412 | } | ||
413 | |||
414 | return 0; | ||
415 | |||
416 | unreg_platform_driver: | ||
417 | platform_driver_unregister(&ibwdt_driver); | ||
418 | return err; | ||
419 | } | ||
420 | |||
421 | static void __exit ibwdt_exit(void) | ||
422 | { | ||
423 | platform_device_unregister(ibwdt_platform_device); | ||
424 | platform_driver_unregister(&ibwdt_driver); | ||
425 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | ||
385 | } | 426 | } |
386 | 427 | ||
387 | module_init(ibwdt_init); | 428 | module_init(ibwdt_init); |