diff options
Diffstat (limited to 'drivers/watchdog/ar7_wdt.c')
| -rw-r--r-- | drivers/watchdog/ar7_wdt.c | 80 |
1 files changed, 28 insertions, 52 deletions
diff --git a/drivers/watchdog/ar7_wdt.c b/drivers/watchdog/ar7_wdt.c index 502773ad5ac..ae6c287a49c 100644 --- a/drivers/watchdog/ar7_wdt.c +++ b/drivers/watchdog/ar7_wdt.c @@ -23,10 +23,11 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/module.h> #include <linux/moduleparam.h> #include <linux/errno.h> -#include <linux/init.h> #include <linux/miscdevice.h> #include <linux/platform_device.h> #include <linux/watchdog.h> @@ -39,20 +40,18 @@ #include <asm/addrspace.h> #include <asm/mach-ar7/ar7.h> -#define DRVNAME "ar7_wdt" #define LONGNAME "TI AR7 Watchdog Timer" MODULE_AUTHOR("Nicolas Thill <nico@openwrt.org>"); MODULE_DESCRIPTION(LONGNAME); MODULE_LICENSE("GPL"); -MODULE_ALIAS_MISCDEV(WATCHDOG_MINOR); static int margin = 60; module_param(margin, int, 0); MODULE_PARM_DESC(margin, "Watchdog margin in seconds"); -static int nowayout = WATCHDOG_NOWAYOUT; -module_param(nowayout, int, 0); +static bool nowayout = WATCHDOG_NOWAYOUT; +module_param(nowayout, bool, 0); MODULE_PARM_DESC(nowayout, "Disable watchdog shutdown on close"); #define READ_REG(x) readl((void __iomem *)&(x)) @@ -93,7 +92,7 @@ static void ar7_wdt_kick(u32 value) return; } } - printk(KERN_ERR DRVNAME ": failed to unlock WDT kick reg\n"); + pr_err("failed to unlock WDT kick reg\n"); } static void ar7_wdt_prescale(u32 value) @@ -106,7 +105,7 @@ static void ar7_wdt_prescale(u32 value) return; } } - printk(KERN_ERR DRVNAME ": failed to unlock WDT prescale reg\n"); + pr_err("failed to unlock WDT prescale reg\n"); } static void ar7_wdt_change(u32 value) @@ -119,7 +118,7 @@ static void ar7_wdt_change(u32 value) return; } } - printk(KERN_ERR DRVNAME ": failed to unlock WDT change reg\n"); + pr_err("failed to unlock WDT change reg\n"); } static void ar7_wdt_disable(u32 value) @@ -135,7 +134,7 @@ static void ar7_wdt_disable(u32 value) } } } - printk(KERN_ERR DRVNAME ": failed to unlock WDT disable reg\n"); + pr_err("failed to unlock WDT disable reg\n"); } static void ar7_wdt_update_margin(int new_margin) @@ -151,21 +150,20 @@ static void ar7_wdt_update_margin(int new_margin) change = 0xffff; ar7_wdt_change(change); margin = change * prescale_value / vbus_rate; - printk(KERN_INFO DRVNAME - ": timer margin %d seconds (prescale %d, change %d, freq %d)\n", - margin, prescale_value, change, vbus_rate); + pr_info("timer margin %d seconds (prescale %d, change %d, freq %d)\n", + margin, prescale_value, change, vbus_rate); } static void ar7_wdt_enable_wdt(void) { - printk(KERN_DEBUG DRVNAME ": enabling watchdog timer\n"); + pr_debug("enabling watchdog timer\n"); ar7_wdt_disable(1); ar7_wdt_kick(1); } static void ar7_wdt_disable_wdt(void) { - printk(KERN_DEBUG DRVNAME ": disabling watchdog timer\n"); + pr_debug("disabling watchdog timer\n"); ar7_wdt_disable(0); } @@ -183,9 +181,7 @@ static int ar7_wdt_open(struct inode *inode, struct file *file) static int ar7_wdt_release(struct inode *inode, struct file *file) { if (!expect_close) - printk(KERN_WARNING DRVNAME - ": watchdog device closed unexpectedly," - "will not disable the watchdog timer\n"); + pr_warn("watchdog device closed unexpectedly, will not disable the watchdog timer\n"); else if (!nowayout) ar7_wdt_disable_wdt(); clear_bit(0, &wdt_is_open); @@ -276,37 +272,20 @@ static struct miscdevice ar7_wdt_miscdev = { .fops = &ar7_wdt_fops, }; -static int __devinit ar7_wdt_probe(struct platform_device *pdev) +static int ar7_wdt_probe(struct platform_device *pdev) { int rc; ar7_regs_wdt = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); - if (!ar7_regs_wdt) { - printk(KERN_ERR DRVNAME ": could not get registers resource\n"); - rc = -ENODEV; - goto out; - } - - if (!request_mem_region(ar7_regs_wdt->start, - resource_size(ar7_regs_wdt), LONGNAME)) { - printk(KERN_WARNING DRVNAME ": watchdog I/O region busy\n"); - rc = -EBUSY; - goto out; - } - - ar7_wdt = ioremap(ar7_regs_wdt->start, resource_size(ar7_regs_wdt)); - if (!ar7_wdt) { - printk(KERN_ERR DRVNAME ": could not ioremap registers\n"); - rc = -ENXIO; - goto out_mem_region; - } + ar7_wdt = devm_ioremap_resource(&pdev->dev, ar7_regs_wdt); + if (IS_ERR(ar7_wdt)) + return PTR_ERR(ar7_wdt); vbus_clk = clk_get(NULL, "vbus"); if (IS_ERR(vbus_clk)) { - printk(KERN_ERR DRVNAME ": could not get vbus clock\n"); - rc = PTR_ERR(vbus_clk); - goto out_mem_region; + pr_err("could not get vbus clock\n"); + return PTR_ERR(vbus_clk); } ar7_wdt_disable_wdt(); @@ -315,25 +294,22 @@ static int __devinit ar7_wdt_probe(struct platform_device *pdev) rc = misc_register(&ar7_wdt_miscdev); if (rc) { - printk(KERN_ERR DRVNAME ": unable to register misc device\n"); - goto out_alloc; + pr_err("unable to register misc device\n"); + goto out; } - goto out; + return 0; -out_alloc: - iounmap(ar7_wdt); -out_mem_region: - release_mem_region(ar7_regs_wdt->start, resource_size(ar7_regs_wdt)); out: + clk_put(vbus_clk); + vbus_clk = NULL; return rc; } -static int __devexit ar7_wdt_remove(struct platform_device *pdev) +static int ar7_wdt_remove(struct platform_device *pdev) { misc_deregister(&ar7_wdt_miscdev); - iounmap(ar7_wdt); - release_mem_region(ar7_regs_wdt->start, resource_size(ar7_regs_wdt)); - + clk_put(vbus_clk); + vbus_clk = NULL; return 0; } @@ -345,7 +321,7 @@ static void ar7_wdt_shutdown(struct platform_device *pdev) static struct platform_driver ar7_wdt_driver = { .probe = ar7_wdt_probe, - .remove = __devexit_p(ar7_wdt_remove), + .remove = ar7_wdt_remove, .shutdown = ar7_wdt_shutdown, .driver = { .owner = THIS_MODULE, |
