diff options
Diffstat (limited to 'drivers/watchdog/riowd.c')
| -rw-r--r-- | drivers/watchdog/riowd.c | 63 |
1 files changed, 26 insertions, 37 deletions
diff --git a/drivers/watchdog/riowd.c b/drivers/watchdog/riowd.c index 1e8f02f440e..cfed0fe264d 100644 --- a/drivers/watchdog/riowd.c +++ b/drivers/watchdog/riowd.c @@ -3,19 +3,20 @@ * Copyright (C) 2001, 2008 David S. Miller (davem@davemloft.net) */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include <linux/kernel.h> #include <linux/module.h> #include <linux/types.h> #include <linux/fs.h> #include <linux/errno.h> -#include <linux/init.h> #include <linux/miscdevice.h> -#include <linux/smp_lock.h> #include <linux/watchdog.h> #include <linux/of.h> #include <linux/of_device.h> #include <linux/io.h> #include <linux/uaccess.h> +#include <linux/slab.h> /* RIO uses the NatSemi Super I/O power management logical device @@ -75,7 +76,6 @@ static void riowd_writereg(struct riowd *p, u8 val, int index) static int riowd_open(struct inode *inode, struct file *filp) { - cycle_kernel_lock(); nonseekable_open(inode, filp); return 0; } @@ -87,7 +87,7 @@ static int riowd_release(struct inode *inode, struct file *filp) static long riowd_ioctl(struct file *filp, unsigned int cmd, unsigned long arg) { - static struct watchdog_info info = { + static const struct watchdog_info info = { .options = WDIOF_SETTIMEOUT, .firmware_version = 1, .identity = DRIVER_NAME, @@ -173,8 +173,7 @@ static struct miscdevice riowd_miscdev = { .fops = &riowd_fops }; -static int __devinit riowd_probe(struct of_device *op, - const struct of_device_id *match) +static int riowd_probe(struct platform_device *op) { struct riowd *p; int err = -EINVAL; @@ -183,7 +182,7 @@ static int __devinit riowd_probe(struct of_device *op, goto out; err = -ENOMEM; - p = kzalloc(sizeof(*p), GFP_KERNEL); + p = devm_kzalloc(&op->dev, sizeof(*p), GFP_KERNEL); if (!p) goto out; @@ -191,40 +190,38 @@ static int __devinit riowd_probe(struct of_device *op, p->regs = of_ioremap(&op->resource[0], 0, 2, DRIVER_NAME); if (!p->regs) { - printk(KERN_ERR PFX "Cannot map registers.\n"); - goto out_free; + pr_err("Cannot map registers\n"); + goto out; } + /* Make miscdev useable right away */ + riowd_device = p; err = misc_register(&riowd_miscdev); if (err) { - printk(KERN_ERR PFX "Cannot register watchdog misc device.\n"); + pr_err("Cannot register watchdog misc device\n"); goto out_iounmap; } - printk(KERN_INFO PFX "Hardware watchdog [%i minutes], " - "regs at %p\n", riowd_timeout, p->regs); + pr_info("Hardware watchdog [%i minutes], regs at %p\n", + riowd_timeout, p->regs); - dev_set_drvdata(&op->dev, p); - riowd_device = p; - err = 0; + platform_set_drvdata(op, p); + return 0; out_iounmap: + riowd_device = NULL; of_iounmap(&op->resource[0], p->regs, 2); -out_free: - kfree(p); - out: return err; } -static int __devexit riowd_remove(struct of_device *op) +static int riowd_remove(struct platform_device *op) { - struct riowd *p = dev_get_drvdata(&op->dev); + struct riowd *p = platform_get_drvdata(op); misc_deregister(&riowd_miscdev); of_iounmap(&op->resource[0], p->regs, 2); - kfree(p); return 0; } @@ -237,22 +234,14 @@ static const struct of_device_id riowd_match[] = { }; MODULE_DEVICE_TABLE(of, riowd_match); -static struct of_platform_driver riowd_driver = { - .name = DRIVER_NAME, - .match_table = riowd_match, +static struct platform_driver riowd_driver = { + .driver = { + .name = DRIVER_NAME, + .owner = THIS_MODULE, + .of_match_table = riowd_match, + }, .probe = riowd_probe, - .remove = __devexit_p(riowd_remove), + .remove = riowd_remove, }; -static int __init riowd_init(void) -{ - return of_register_driver(&riowd_driver, &of_bus_type); -} - -static void __exit riowd_exit(void) -{ - of_unregister_driver(&riowd_driver); -} - -module_init(riowd_init); -module_exit(riowd_exit); +module_platform_driver(riowd_driver); |
