[WATCHDOG] advantechwdt.c - convert to platform_device
Convert the advantechwdt watchdog into a platform_device Signed-off-by: Wim Van Sebroeck <wim@iguana.be>
This commit is contained in:
parent
0349a363e2
commit
c2bd11c7cb
|
@ -37,6 +37,7 @@
|
||||||
#include <linux/ioport.h>
|
#include <linux/ioport.h>
|
||||||
#include <linux/notifier.h>
|
#include <linux/notifier.h>
|
||||||
#include <linux/reboot.h>
|
#include <linux/reboot.h>
|
||||||
|
#include <linux/platform_device.h>
|
||||||
#include <linux/init.h>
|
#include <linux/init.h>
|
||||||
|
|
||||||
#include <asm/io.h>
|
#include <asm/io.h>
|
||||||
|
@ -48,6 +49,7 @@
|
||||||
#define WATCHDOG_NAME "Advantech WDT"
|
#define WATCHDOG_NAME "Advantech WDT"
|
||||||
#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */
|
#define WATCHDOG_TIMEOUT 60 /* 60 sec default timeout */
|
||||||
|
|
||||||
|
static struct platform_device *advwdt_platform_device; /* the watchdog platform device */
|
||||||
static unsigned long advwdt_is_open;
|
static unsigned long advwdt_is_open;
|
||||||
static char adv_expect_close;
|
static char adv_expect_close;
|
||||||
|
|
||||||
|
@ -269,13 +271,11 @@ static struct notifier_block advwdt_notifier = {
|
||||||
* Init & exit routines
|
* Init & exit routines
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static int __init
|
static int __devinit
|
||||||
advwdt_init(void)
|
advwdt_probe(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
printk(KERN_INFO "WDT driver for Advantech single board computer initialising.\n");
|
|
||||||
|
|
||||||
if (wdt_stop != wdt_start) {
|
if (wdt_stop != wdt_start) {
|
||||||
if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
|
if (!request_region(wdt_stop, 1, WATCHDOG_NAME)) {
|
||||||
printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
|
printk (KERN_ERR PFX "I/O address 0x%04x already in use\n",
|
||||||
|
@ -328,14 +328,57 @@ unreg_stop:
|
||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit
|
static int __devexit
|
||||||
advwdt_exit(void)
|
advwdt_remove(struct platform_device *dev)
|
||||||
{
|
{
|
||||||
misc_deregister(&advwdt_miscdev);
|
misc_deregister(&advwdt_miscdev);
|
||||||
unregister_reboot_notifier(&advwdt_notifier);
|
unregister_reboot_notifier(&advwdt_notifier);
|
||||||
release_region(wdt_start,1);
|
release_region(wdt_start,1);
|
||||||
if(wdt_stop != wdt_start)
|
if(wdt_stop != wdt_start)
|
||||||
release_region(wdt_stop,1);
|
release_region(wdt_stop,1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static struct platform_driver advwdt_driver = {
|
||||||
|
.probe = advwdt_probe,
|
||||||
|
.remove = __devexit_p(advwdt_remove),
|
||||||
|
.driver = {
|
||||||
|
.owner = THIS_MODULE,
|
||||||
|
.name = DRV_NAME,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
static int __init
|
||||||
|
advwdt_init(void)
|
||||||
|
{
|
||||||
|
int err;
|
||||||
|
|
||||||
|
printk(KERN_INFO "WDT driver for Advantech single board computer initialising.\n");
|
||||||
|
|
||||||
|
err = platform_driver_register(&advwdt_driver);
|
||||||
|
if (err)
|
||||||
|
return err;
|
||||||
|
|
||||||
|
advwdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0);
|
||||||
|
if (IS_ERR(advwdt_platform_device)) {
|
||||||
|
err = PTR_ERR(advwdt_platform_device);
|
||||||
|
goto unreg_platform_driver;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
unreg_platform_driver:
|
||||||
|
platform_driver_unregister(&advwdt_driver);
|
||||||
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void __exit
|
||||||
|
advwdt_exit(void)
|
||||||
|
{
|
||||||
|
platform_device_unregister(advwdt_platform_device);
|
||||||
|
platform_driver_unregister(&advwdt_driver);
|
||||||
|
printk(KERN_INFO PFX "Watchdog Module Unloaded.\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(advwdt_init);
|
module_init(advwdt_init);
|
||||||
|
|
Loading…
Reference in New Issue