From 3836cc0ff8c875e21a8119e7a4f0227f6e227650 Mon Sep 17 00:00:00 2001 From: Wim Van Sebroeck Date: Fri, 30 Jun 2006 08:44:53 +0200 Subject: [PATCH] [WATCHDOG] iTCO_wdt (Intel TCO Timer) driver Convert the iTCO_wdt driver to a platform device driver. Signed-off-by: Wim Van Sebroeck --- drivers/char/watchdog/iTCO_wdt.c | 103 ++++++++++++++++++++++++------- 1 file changed, 79 insertions(+), 24 deletions(-) diff --git a/drivers/char/watchdog/iTCO_wdt.c b/drivers/char/watchdog/iTCO_wdt.c index c1a5787fde5..cbdfbf00cfb 100644 --- a/drivers/char/watchdog/iTCO_wdt.c +++ b/drivers/char/watchdog/iTCO_wdt.c @@ -45,28 +45,29 @@ /* Module and version information */ #define DRV_NAME "iTCO_wdt" #define DRV_VERSION "1.00" -#define DRV_RELDATE "21-May-2006" +#define DRV_RELDATE "18-Jun-2006" #define PFX DRV_NAME ": " /* Includes */ -#include /* For CONFIG_WATCHDOG_NOWAYOUT/... */ -#include /* For module specific items */ -#include /* For new moduleparam's */ -#include /* For standard types (like size_t) */ -#include /* For the -ENODEV/... values */ -#include /* For printk/panic/... */ -#include /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ -#include /* For the watchdog specific items */ -#include /* For notifier support */ -#include /* For reboot_notifier stuff */ -#include /* For __init/__exit/... */ -#include /* For file operations */ -#include /* For pci functions */ -#include /* For io-port access */ -#include /* For spin_lock/spin_unlock/... */ - -#include /* For copy_to_user/put_user/... */ -#include /* For inb/outb/... */ +#include /* For CONFIG_WATCHDOG_NOWAYOUT/... */ +#include /* For module specific items */ +#include /* For new moduleparam's */ +#include /* For standard types (like size_t) */ +#include /* For the -ENODEV/... values */ +#include /* For printk/panic/... */ +#include /* For MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR) */ +#include /* For the watchdog specific items */ +#include /* For notifier support */ +#include /* For reboot_notifier stuff */ +#include /* For __init/__exit/... */ +#include /* For file operations */ +#include /* For platform_driver framework */ +#include /* For pci functions */ +#include /* For io-port access */ +#include /* For spin_lock/spin_unlock/... */ + +#include /* For copy_to_user/put_user/... */ +#include /* For inb/outb/... */ /* TCO related info */ enum iTCO_chipsets { @@ -166,6 +167,8 @@ static struct { /* this is private data for the iTCO_wdt device */ struct pci_dev *pdev; /* the PCI-device */ } iTCO_wdt_private; +static struct platform_device *iTCO_wdt_platform_device; /* the watchdog platform device */ + /* module parameters */ #define WATCHDOG_HEARTBEAT 30 /* 30 sec default heartbeat */ static int heartbeat = WATCHDOG_HEARTBEAT; /* in seconds */ @@ -538,7 +541,7 @@ static struct notifier_block iTCO_wdt_notifier = { * 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; u32 base_address; @@ -649,7 +652,7 @@ out: return ret; } -static void __exit iTCO_wdt_cleanup(void) +static void iTCO_wdt_cleanup(void) { /* Stop the timer before we leave */ if (!nowayout) @@ -663,7 +666,7 @@ static void __exit iTCO_wdt_cleanup(void) 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; struct pci_dev *pdev = NULL; @@ -674,7 +677,7 @@ static int __init iTCO_wdt_init_module(void) for_each_pci_dev(pdev) { ent = pci_match_id(iTCO_wdt_pci_tbl, pdev); if (ent) { - if (!(iTCO_wdt_init(pdev, ent))) { + if (!(iTCO_wdt_init(pdev, ent, dev))) { found++; break; } @@ -689,11 +692,62 @@ static int __init iTCO_wdt_init_module(void) return 0; } -static void __exit iTCO_wdt_cleanup_module(void) +static int iTCO_wdt_remove(struct platform_device *dev) { if (iTCO_wdt_private.ACPIBASE) 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"); } @@ -702,5 +756,6 @@ module_exit(iTCO_wdt_cleanup_module); MODULE_AUTHOR("Wim Van Sebroeck "); MODULE_DESCRIPTION("Intel TCO WatchDog Timer Driver"); +MODULE_VERSION(DRV_VERSION); MODULE_LICENSE("GPL"); MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); -- 2.41.0