Commit 3836cc0f authored by Wim Van Sebroeck's avatar Wim Van Sebroeck

[WATCHDOG] iTCO_wdt (Intel TCO Timer) driver

Convert the iTCO_wdt driver to a platform device
driver.
Signed-off-by: default avatarWim Van Sebroeck <wim@iguana.be>
parent 9e0ea345
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
/* Module and version information */ /* Module and version information */
#define DRV_NAME "iTCO_wdt" #define DRV_NAME "iTCO_wdt"
#define DRV_VERSION "1.00" #define DRV_VERSION "1.00"
#define DRV_RELDATE "21-May-2006" #define DRV_RELDATE "18-Jun-2006"
#define PFX DRV_NAME ": " #define PFX DRV_NAME ": "
/* Includes */ /* Includes */
...@@ -61,6 +61,7 @@ ...@@ -61,6 +61,7 @@
#include <linux/reboot.h> /* For reboot_notifier stuff */ #include <linux/reboot.h> /* For reboot_notifier stuff */
#include <linux/init.h> /* For __init/__exit/... */ #include <linux/init.h> /* For __init/__exit/... */
#include <linux/fs.h> /* For file operations */ #include <linux/fs.h> /* For file operations */
#include <linux/platform_device.h> /* For platform_driver framework */
#include <linux/pci.h> /* For pci functions */ #include <linux/pci.h> /* For pci functions */
#include <linux/ioport.h> /* For io-port access */ #include <linux/ioport.h> /* For io-port access */
#include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */
...@@ -166,6 +167,8 @@ static struct { /* this is private data for the iTCO_wdt device */ ...@@ -166,6 +167,8 @@ static struct { /* this is private data for the iTCO_wdt device */
struct pci_dev *pdev; /* the PCI-device */ struct pci_dev *pdev; /* the PCI-device */
} iTCO_wdt_private; } iTCO_wdt_private;
static struct platform_device *iTCO_wdt_platform_device; /* the watchdog platform device */
/* module parameters */ /* module parameters */
#define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */
static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */
...@@ -538,7 +541,7 @@ static struct notifier_block iTCO_wdt_notifier = { ...@@ -538,7 +541,7 @@ static struct notifier_block iTCO_wdt_notifier = {
* Init & exit routines * Init & exit routines
*/ */
static int __init iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent) static int iTCO_wdt_init(struct pci_dev *pdev, const struct pci_device_id *ent, struct platform_device *dev)
{ {
int ret; int ret;
u32 base_address; u32 base_address;
...@@ -649,7 +652,7 @@ out: ...@@ -649,7 +652,7 @@ out:
return ret; return ret;
} }
static void __exit iTCO_wdt_cleanup(void) static void iTCO_wdt_cleanup(void)
{ {
/* Stop the timer before we leave */ /* Stop the timer before we leave */
if (!nowayout) if (!nowayout)
...@@ -663,7 +666,7 @@ static void __exit iTCO_wdt_cleanup(void) ...@@ -663,7 +666,7 @@ static void __exit iTCO_wdt_cleanup(void)
iounmap(iTCO_wdt_private.gcs); iounmap(iTCO_wdt_private.gcs);
} }
static int __init iTCO_wdt_init_module(void) static int iTCO_wdt_probe(struct platform_device *dev)
{ {
int found = 0; int found = 0;
struct pci_dev *pdev = NULL; struct pci_dev *pdev = NULL;
...@@ -674,7 +677,7 @@ static int __init iTCO_wdt_init_module(void) ...@@ -674,7 +677,7 @@ static int __init iTCO_wdt_init_module(void)
for_each_pci_dev(pdev) { for_each_pci_dev(pdev) {
ent = pci_match_id(iTCO_wdt_pci_tbl, pdev); ent = pci_match_id(iTCO_wdt_pci_tbl, pdev);
if (ent) { if (ent) {
if (!(iTCO_wdt_init(pdev, ent))) { if (!(iTCO_wdt_init(pdev, ent, dev))) {
found++; found++;
break; break;
} }
...@@ -689,11 +692,62 @@ static int __init iTCO_wdt_init_module(void) ...@@ -689,11 +692,62 @@ static int __init iTCO_wdt_init_module(void)
return 0; return 0;
} }
static void __exit iTCO_wdt_cleanup_module(void) static int iTCO_wdt_remove(struct platform_device *dev)
{ {
if (iTCO_wdt_private.ACPIBASE) if (iTCO_wdt_private.ACPIBASE)
iTCO_wdt_cleanup(); iTCO_wdt_cleanup();
return 0;
}
static void iTCO_wdt_shutdown(struct platform_device *dev)
{
iTCO_wdt_stop();
}
#define iTCO_wdt_suspend NULL
#define iTCO_wdt_resume NULL
static struct platform_driver iTCO_wdt_driver = {
.probe = iTCO_wdt_probe,
.remove = iTCO_wdt_remove,
.shutdown = iTCO_wdt_shutdown,
.suspend = iTCO_wdt_suspend,
.resume = iTCO_wdt_resume,
.driver = {
.owner = THIS_MODULE,
.name = DRV_NAME,
},
};
static int __init iTCO_wdt_init_module(void)
{
int err;
printk(KERN_INFO PFX "Intel TCO WatchDog Timer Driver v%s (%s)\n",
DRV_VERSION, DRV_RELDATE);
err = platform_driver_register(&iTCO_wdt_driver);
if (err)
return err;
iTCO_wdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0);
if (IS_ERR(iTCO_wdt_platform_device)) {
err = PTR_ERR(iTCO_wdt_platform_device);
goto unreg_platform_driver;
}
return 0;
unreg_platform_driver:
platform_driver_unregister(&iTCO_wdt_driver);
return err;
}
static void __exit iTCO_wdt_cleanup_module(void)
{
platform_device_unregister(iTCO_wdt_platform_device);
platform_driver_unregister(&iTCO_wdt_driver);
printk(KERN_INFO PFX "Watchdog Module Unloaded.\n"); printk(KERN_INFO PFX "Watchdog Module Unloaded.\n");
} }
...@@ -702,5 +756,6 @@ module_exit(iTCO_wdt_cleanup_module); ...@@ -702,5 +756,6 @@ module_exit(iTCO_wdt_cleanup_module);
MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>"); MODULE_AUTHOR("Wim Van Sebroeck <wim@iguana.be>");
MODULE_DESCRIPTION("Intel TCO WatchDog Timer Driver"); MODULE_DESCRIPTION("Intel TCO WatchDog Timer Driver");
MODULE_VERSION(DRV_VERSION);
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment