diff options
author | Wim Van Sebroeck <wim@iguana.be> | 2007-01-10 17:36:13 -0500 |
---|---|---|
committer | Wim Van Sebroeck <wim@iguana.be> | 2007-01-10 17:36:13 -0500 |
commit | ad5fe323182fd3adab4225c93eae36f3c555a884 (patch) | |
tree | 6b315f85dc2a26a49f7dcbfd3212c3d6d9fcac34 /drivers/char/watchdog | |
parent | 76c11f0442257099cbb474301f2ffff38649d3d3 (diff) |
[WATCHDOG] acquirewdt.c - convert to platform_device
Convert the acquirewdt 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/acquirewdt.c | 49 |
1 files changed, 45 insertions, 4 deletions
diff --git a/drivers/char/watchdog/acquirewdt.c b/drivers/char/watchdog/acquirewdt.c index a968f84c353e..687b809d49cb 100644 --- a/drivers/char/watchdog/acquirewdt.c +++ b/drivers/char/watchdog/acquirewdt.c | |||
@@ -64,6 +64,7 @@ | |||
64 | #include <linux/ioport.h> /* For io-port access */ | 64 | #include <linux/ioport.h> /* For io-port access */ |
65 | #include <linux/notifier.h> /* For reboot notifier */ | 65 | #include <linux/notifier.h> /* For reboot notifier */ |
66 | #include <linux/reboot.h> /* For reboot notifier */ | 66 | #include <linux/reboot.h> /* For reboot notifier */ |
67 | #include <linux/platform_device.h> /* For platform_driver framework */ | ||
67 | #include <linux/init.h> /* For __init/__exit/... */ | 68 | #include <linux/init.h> /* For __init/__exit/... */ |
68 | 69 | ||
69 | #include <asm/uaccess.h> /* For copy_to_user/put_user/... */ | 70 | #include <asm/uaccess.h> /* For copy_to_user/put_user/... */ |
@@ -76,6 +77,7 @@ | |||
76 | #define WATCHDOG_HEARTBEAT 0 /* There is no way to see what the correct time-out period is */ | 77 | #define WATCHDOG_HEARTBEAT 0 /* There is no way to see what the correct time-out period is */ |
77 | 78 | ||
78 | /* internal variables */ | 79 | /* internal variables */ |
80 | static struct platform_device *acq_platform_device; /* the watchdog platform device */ | ||
79 | static unsigned long acq_is_open; | 81 | static unsigned long acq_is_open; |
80 | static char expect_close; | 82 | static char expect_close; |
81 | 83 | ||
@@ -265,12 +267,10 @@ static struct notifier_block acq_notifier = { | |||
265 | * Init & exit routines | 267 | * Init & exit routines |
266 | */ | 268 | */ |
267 | 269 | ||
268 | static int __init acq_init(void) | 270 | static int __devinit acq_probe(struct platform_device *dev) |
269 | { | 271 | { |
270 | int ret; | 272 | int ret; |
271 | 273 | ||
272 | printk(KERN_INFO "WDT driver for Acquire single board computer initialising.\n"); | ||
273 | |||
274 | if (wdt_stop != wdt_start) { | 274 | if (wdt_stop != wdt_start) { |
275 | if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { | 275 | if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) { |
276 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", | 276 | printk (KERN_ERR PFX "I/O address 0x%04x already in use\n", |
@@ -317,13 +317,54 @@ out: | |||
317 | return ret; | 317 | return ret; |
318 | } | 318 | } |
319 | 319 | ||
320 | static void __exit acq_exit(void) | 320 | static int __devexit acq_remove(struct platform_device *dev) |
321 | { | 321 | { |
322 | misc_deregister(&acq_miscdev); | 322 | misc_deregister(&acq_miscdev); |
323 | unregister_reboot_notifier(&acq_notifier); | 323 | unregister_reboot_notifier(&acq_notifier); |
324 | release_region(wdt_start,1); | 324 | release_region(wdt_start,1); |
325 | if(wdt_stop != wdt_start) | 325 | if(wdt_stop != wdt_start) |
326 | release_region(wdt_stop,1); | 326 | release_region(wdt_stop,1); |
327 | |||
328 | return 0; | ||
329 | } | ||
330 | |||
331 | static struct platform_driver acquirewdt_driver = { | ||
332 | .probe = acq_probe, | ||
333 | .remove = __devexit_p(acq_remove), | ||
334 | .driver = { | ||
335 | .owner = THIS_MODULE, | ||
336 | .name = DRV_NAME, | ||
337 | }, | ||
338 | }; | ||
339 | |||
340 | static int __init acq_init(void) | ||
341 | { | ||
342 | int err; | ||
343 | |||
344 | printk(KERN_INFO "WDT driver for Acquire single board computer initialising.\n"); | ||
345 | |||
346 | err = platform_driver_register(&acquirewdt_driver); | ||
347 | if (err) | ||
348 | return err; | ||
349 | |||
350 | acq_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0); | ||
351 | if (IS_ERR(acq_platform_device)) { | ||
352 | err = PTR_ERR(acq_platform_device); | ||
353 | goto unreg_platform_driver; | ||
354 | } | ||
355 | |||
356 | return 0; | ||
357 | |||
358 | unreg_platform_driver: | ||
359 | platform_driver_unregister(&acquirewdt_driver); | ||
360 | return err; | ||
361 | } | ||
362 | |||
363 | static void __exit acq_exit(void) | ||
364 | { | ||
365 | platform_device_unregister(acq_platform_device); | ||
366 | platform_driver_unregister(&acquirewdt_driver); | ||
367 | printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); | ||
327 | } | 368 | } |
328 | 369 | ||
329 | module_init(acq_init); | 370 | module_init(acq_init); |