diff options
Diffstat (limited to 'drivers/watchdog/rc32434_wdt.c')
| -rw-r--r-- | drivers/watchdog/rc32434_wdt.c | 66 |
1 files changed, 22 insertions, 44 deletions
diff --git a/drivers/watchdog/rc32434_wdt.c b/drivers/watchdog/rc32434_wdt.c index d4c29b5311a..71e78ef4b73 100644 --- a/drivers/watchdog/rc32434_wdt.c +++ b/drivers/watchdog/rc32434_wdt.c @@ -17,24 +17,24 @@ * */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/module.h> /* For module specific items */ #include <linux/moduleparam.h> /* For new moduleparam's */ #include <linux/types.h> /* For standard types (like size_t) */ #include <linux/errno.h> /* For the -ENODEV/... values */ #include <linux/kernel.h> /* For printk/panic/... */ #include <linux/fs.h> /* For file operations */ -#include <linux/miscdevice.h> /* For MODULE_ALIAS_MISCDEV - (WATCHDOG_MINOR) */ +#include <linux/miscdevice.h> /* For struct miscdevice */ #include <linux/watchdog.h> /* For the watchdog specific items */ #include <linux/init.h> /* For __init/__exit/... */ #include <linux/platform_device.h> /* For platform_driver framework */ #include <linux/spinlock.h> /* For spin_lock/spin_unlock/... */ #include <linux/uaccess.h> /* For copy_to_user/put_user/... */ +#include <linux/io.h> /* For devm_ioremap_nocache */ #include <asm/mach-rc32434/integ.h> /* For the Watchdog registers */ -#define PFX KBUILD_MODNAME ": " - #define VERSION "1.0" static struct { @@ -64,8 +64,8 @@ module_param(timeout, int, 0); MODULE_PARM_DESC(timeout, "Watchdog timeout value, in seconds (default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ")"); -static int nowayout = WATCHDOG_NOWAYOUT; -module_param(nowayout, int, 0); +static bool nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")"); @@ -78,8 +78,7 @@ static int rc32434_wdt_set(int new_timeout) int max_to = WTCOMP2SEC((u32)-1); if (new_timeout < 0 || new_timeout > max_to) { - printk(KERN_ERR PFX "timeout value must be between 0 and %d", - max_to); + pr_err("timeout value must be between 0 and %d\n", max_to); return -EINVAL; } timeout = new_timeout; @@ -119,7 +118,7 @@ static void rc32434_wdt_start(void) SET_BITS(wdt_reg->wtc, or, nand); spin_unlock(&rc32434_wdt_device.io_lock); - printk(KERN_INFO PFX "Started watchdog timer.\n"); + pr_info("Started watchdog timer\n"); } static void rc32434_wdt_stop(void) @@ -130,7 +129,7 @@ static void rc32434_wdt_stop(void) SET_BITS(wdt_reg->wtc, 0, 1 << RC32434_WTC_EN); spin_unlock(&rc32434_wdt_device.io_lock); - printk(KERN_INFO PFX "Stopped watchdog timer.\n"); + pr_info("Stopped watchdog timer\n"); } static void rc32434_wdt_ping(void) @@ -160,8 +159,7 @@ static int rc32434_wdt_release(struct inode *inode, struct file *file) rc32434_wdt_stop(); module_put(THIS_MODULE); } else { - printk(KERN_CRIT PFX - "device closed unexpectedly. WDT will not stop!\n"); + pr_crit("device closed unexpectedly. WDT will not stop!\n"); rc32434_wdt_ping(); } clear_bit(0, &rc32434_wdt_device.inuse); @@ -262,23 +260,20 @@ static struct miscdevice rc32434_wdt_miscdev = { .fops = &rc32434_wdt_fops, }; -static char banner[] __devinitdata = KERN_INFO PFX - "Watchdog Timer version " VERSION ", timer margin: %d sec\n"; - -static int __devinit rc32434_wdt_probe(struct platform_device *pdev) +static int rc32434_wdt_probe(struct platform_device *pdev) { int ret; struct resource *r; r = platform_get_resource_byname(pdev, IORESOURCE_MEM, "rb532_wdt_res"); if (!r) { - printk(KERN_ERR PFX "failed to retrieve resources\n"); + pr_err("failed to retrieve resources\n"); return -ENODEV; } - wdt_reg = ioremap_nocache(r->start, resource_size(r)); + wdt_reg = devm_ioremap_nocache(&pdev->dev, r->start, resource_size(r)); if (!wdt_reg) { - printk(KERN_ERR PFX "failed to remap I/O resources\n"); + pr_err("failed to remap I/O resources\n"); return -ENXIO; } @@ -291,30 +286,25 @@ static int __devinit rc32434_wdt_probe(struct platform_device *pdev) * if not reset to the default */ if (rc32434_wdt_set(timeout)) { rc32434_wdt_set(WATCHDOG_TIMEOUT); - printk(KERN_INFO PFX - "timeout value must be between 0 and %d\n", + pr_info("timeout value must be between 0 and %d\n", WTCOMP2SEC((u32)-1)); } ret = misc_register(&rc32434_wdt_miscdev); if (ret < 0) { - printk(KERN_ERR PFX "failed to register watchdog device\n"); - goto unmap; + pr_err("failed to register watchdog device\n"); + return ret; } - printk(banner, timeout); + pr_info("Watchdog Timer version " VERSION ", timer margin: %d sec\n", + timeout); return 0; - -unmap: - iounmap(wdt_reg); - return ret; } -static int __devexit rc32434_wdt_remove(struct platform_device *pdev) +static int rc32434_wdt_remove(struct platform_device *pdev) { misc_deregister(&rc32434_wdt_miscdev); - iounmap(wdt_reg); return 0; } @@ -325,28 +315,16 @@ static void rc32434_wdt_shutdown(struct platform_device *pdev) static struct platform_driver rc32434_wdt_driver = { .probe = rc32434_wdt_probe, - .remove = __devexit_p(rc32434_wdt_remove), + .remove = rc32434_wdt_remove, .shutdown = rc32434_wdt_shutdown, .driver = { .name = "rc32434_wdt", } }; -static int __init rc32434_wdt_init(void) -{ - return platform_driver_register(&rc32434_wdt_driver); -} - -static void __exit rc32434_wdt_exit(void) -{ - platform_driver_unregister(&rc32434_wdt_driver); -} - -module_init(rc32434_wdt_init); -module_exit(rc32434_wdt_exit); +module_platform_driver(rc32434_wdt_driver); MODULE_AUTHOR("Ondrej Zajicek <santiago@crfreenet.org>," "Florian Fainelli <florian@openwrt.org>"); MODULE_DESCRIPTION("Driver for the IDT RC32434 SoC watchdog"); MODULE_LICENSE("GPL"); -MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); |
