[WATCHDOG] NS pc87413-wdt Watchdog driver - fixes
[safe/jmp/linux-2.6] / drivers / char / watchdog / mv64x60_wdt.c
index 04e0d7e..b887cdb 100644 (file)
@@ -15,7 +15,6 @@
  * or implied.
  */
 
-#include <linux/config.h>
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
@@ -161,13 +160,13 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file,
                break;
 
        default:
-               return -ENOIOCTLCMD;
+               return -ENOTTY;
        }
 
        return 0;
 }
 
-static struct file_operations mv64x60_wdt_fops = {
+static const struct file_operations mv64x60_wdt_fops = {
        .owner = THIS_MODULE,
        .llseek = no_llseek,
        .write = mv64x60_wdt_write,
@@ -182,10 +181,9 @@ static struct miscdevice mv64x60_wdt_miscdev = {
        .fops = &mv64x60_wdt_fops,
 };
 
-static int __devinit mv64x60_wdt_probe(struct device *dev)
+static int __devinit mv64x60_wdt_probe(struct platform_device *dev)
 {
-       struct platform_device *pd = to_platform_device(dev);
-       struct mv64x60_wdt_pdata *pdata = pd->dev.platform_data;
+       struct mv64x60_wdt_pdata *pdata = dev->dev.platform_data;
        int bus_clk = 133;
 
        mv64x60_wdt_timeout = 10;
@@ -202,7 +200,7 @@ static int __devinit mv64x60_wdt_probe(struct device *dev)
        return misc_register(&mv64x60_wdt_miscdev);
 }
 
-static int __devexit mv64x60_wdt_remove(struct device *dev)
+static int __devexit mv64x60_wdt_remove(struct platform_device *dev)
 {
        misc_deregister(&mv64x60_wdt_miscdev);
 
@@ -212,11 +210,13 @@ static int __devexit mv64x60_wdt_remove(struct device *dev)
        return 0;
 }
 
-static struct device_driver mv64x60_wdt_driver = {
-       .name = MV64x60_WDT_NAME,
-       .bus = &platform_bus_type,
+static struct platform_driver mv64x60_wdt_driver = {
        .probe = mv64x60_wdt_probe,
        .remove = __devexit_p(mv64x60_wdt_remove),
+       .driver = {
+               .owner = THIS_MODULE,
+               .name = MV64x60_WDT_NAME,
+       },
 };
 
 static struct platform_device *mv64x60_wdt_dev;
@@ -227,21 +227,31 @@ static int __init mv64x60_wdt_init(void)
 
        printk(KERN_INFO "MV64x60 watchdog driver\n");
 
-       mv64x60_wdt_dev = platform_device_register_simple(MV64x60_WDT_NAME,
-                                                         -1, NULL, 0);
-       if (IS_ERR(mv64x60_wdt_dev)) {
-               ret = PTR_ERR(mv64x60_wdt_dev);
+       mv64x60_wdt_dev = platform_device_alloc(MV64x60_WDT_NAME, -1);
+       if (!mv64x60_wdt_dev) {
+               ret = -ENOMEM;
                goto out;
        }
 
-       ret = driver_register(&mv64x60_wdt_driver);
-      out:
+       ret = platform_device_add(mv64x60_wdt_dev);
+       if (ret) {
+               platform_device_put(mv64x60_wdt_dev);
+               goto out;
+       }
+
+       ret = platform_driver_register(&mv64x60_wdt_driver);
+       if (ret) {
+               platform_device_unregister(mv64x60_wdt_dev);
+               goto out;
+       }
+
+ out:
        return ret;
 }
 
 static void __exit mv64x60_wdt_exit(void)
 {
-       driver_unregister(&mv64x60_wdt_driver);
+       platform_driver_unregister(&mv64x60_wdt_driver);
        platform_device_unregister(mv64x60_wdt_dev);
 }