ath9k: add a workaround for ack timeout issues
[safe/jmp/linux-2.6] / drivers / watchdog / geodewdt.c
index f85b196..9acf001 100644 (file)
@@ -17,8 +17,8 @@
 #include <linux/fs.h>
 #include <linux/platform_device.h>
 #include <linux/reboot.h>
+#include <linux/uaccess.h>
 
-#include <asm/uaccess.h>
 #include <asm/geode.h>
 
 #define GEODEWDT_HZ 500
 
 static int timeout = WATCHDOG_TIMEOUT;
 module_param(timeout, int, 0);
-MODULE_PARM_DESC(timeout, "Watchdog timeout in seconds. 1<= timeout <=131, default=" __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
+MODULE_PARM_DESC(timeout,
+       "Watchdog timeout in seconds. 1<= timeout <=131, default="
+                               __MODULE_STRING(WATCHDOG_TIMEOUT) ".");
 
 static int nowayout = WATCHDOG_NOWAYOUT;
 module_param(nowayout, int, 0);
-MODULE_PARM_DESC(nowayout, "Watchdog cannot be stopped once started (default=" __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
+MODULE_PARM_DESC(nowayout,
+       "Watchdog cannot be stopped once started (default="
+                               __MODULE_STRING(WATCHDOG_NOWAYOUT) ")");
 
 static struct platform_device *geodewdt_platform_device;
 static unsigned long wdt_flags;
@@ -77,27 +81,24 @@ static int geodewdt_set_heartbeat(int val)
        return 0;
 }
 
-static int
-geodewdt_open(struct inode *inode, struct file *file)
+static int geodewdt_open(struct inode *inode, struct file *file)
 {
-        if (test_and_set_bit(WDT_FLAGS_OPEN, &wdt_flags))
-                return -EBUSY;
+       if (test_and_set_bit(WDT_FLAGS_OPEN, &wdt_flags))
+               return -EBUSY;
 
-        if (!test_and_clear_bit(WDT_FLAGS_ORPHAN, &wdt_flags))
-                __module_get(THIS_MODULE);
+       if (!test_and_clear_bit(WDT_FLAGS_ORPHAN, &wdt_flags))
+               __module_get(THIS_MODULE);
 
        geodewdt_ping();
-        return nonseekable_open(inode, file);
+       return nonseekable_open(inode, file);
 }
 
-static int
-geodewdt_release(struct inode *inode, struct file *file)
+static int geodewdt_release(struct inode *inode, struct file *file)
 {
        if (safe_close) {
                geodewdt_disable();
                module_put(THIS_MODULE);
-       }
-       else {
+       } else {
                printk(KERN_CRIT "Unexpected close - watchdog is not stopping.\n");
                geodewdt_ping();
 
@@ -109,11 +110,10 @@ geodewdt_release(struct inode *inode, struct file *file)
        return 0;
 }
 
-static ssize_t
-geodewdt_write(struct file *file, const char __user *data, size_t len,
-              loff_t *ppos)
+static ssize_t geodewdt_write(struct file *file, const char __user *data,
+                               size_t len, loff_t *ppos)
 {
-        if(len) {
+       if (len) {
                if (!nowayout) {
                        size_t i;
                        safe_close = 0;
@@ -134,9 +134,8 @@ geodewdt_write(struct file *file, const char __user *data, size_t len,
        return len;
 }
 
-static int
-geodewdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
-              unsigned long arg)
+static long geodewdt_ioctl(struct file *file, unsigned int cmd,
+                               unsigned long arg)
 {
        void __user *argp = (void __user *)arg;
        int __user *p = argp;
@@ -147,9 +146,9 @@ geodewdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
                | WDIOF_MAGICCLOSE,
                .firmware_version =     1,
                .identity =             WATCHDOG_NAME,
-        };
+       };
 
-       switch(cmd) {
+       switch (cmd) {
        case WDIOC_GETSUPPORT:
                return copy_to_user(argp, &ident,
                                    sizeof(ident)) ? -EFAULT : 0;
@@ -159,22 +158,6 @@ geodewdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
        case WDIOC_GETBOOTSTATUS:
                return put_user(0, p);
 
-       case WDIOC_KEEPALIVE:
-               geodewdt_ping();
-               return 0;
-
-       case WDIOC_SETTIMEOUT:
-               if (get_user(interval, p))
-                       return -EFAULT;
-
-               if (geodewdt_set_heartbeat(interval))
-                       return -EINVAL;
-
-/* Fall through */
-
-       case WDIOC_GETTIMEOUT:
-               return put_user(timeout, p);
-
        case WDIOC_SETOPTIONS:
        {
                int options, ret = -EINVAL;
@@ -194,6 +177,20 @@ geodewdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 
                return ret;
        }
+       case WDIOC_KEEPALIVE:
+               geodewdt_ping();
+               return 0;
+
+       case WDIOC_SETTIMEOUT:
+               if (get_user(interval, p))
+                       return -EFAULT;
+
+               if (geodewdt_set_heartbeat(interval))
+                       return -EINVAL;
+       /* Fall through */
+       case WDIOC_GETTIMEOUT:
+               return put_user(timeout, p);
+
        default:
                return -ENOTTY;
        }
@@ -202,27 +199,25 @@ geodewdt_ioctl(struct inode *inode, struct file *file, unsigned int cmd,
 }
 
 static const struct file_operations geodewdt_fops = {
-        .owner          = THIS_MODULE,
-        .llseek         = no_llseek,
-        .write          = geodewdt_write,
-        .ioctl          = geodewdt_ioctl,
-        .open           = geodewdt_open,
-        .release        = geodewdt_release,
+       .owner          = THIS_MODULE,
+       .llseek         = no_llseek,
+       .write          = geodewdt_write,
+       .unlocked_ioctl = geodewdt_ioctl,
+       .open           = geodewdt_open,
+       .release        = geodewdt_release,
 };
 
 static struct miscdevice geodewdt_miscdev = {
        .minor = WATCHDOG_MINOR,
        .name = "watchdog",
-       .fops = &geodewdt_fops
+       .fops = &geodewdt_fops,
 };
 
-static int __devinit
-geodewdt_probe(struct platform_device *dev)
+static int __devinit geodewdt_probe(struct platform_device *dev)
 {
        int ret, timer;
 
-       timer = geode_mfgpt_alloc_timer(MFGPT_TIMER_ANY,
-                                       MFGPT_DOMAIN_WORKING, THIS_MODULE);
+       timer = geode_mfgpt_alloc_timer(MFGPT_TIMER_ANY, MFGPT_DOMAIN_WORKING);
 
        if (timer == -1) {
                printk(KERN_ERR "geodewdt:  No timers were available\n");
@@ -249,15 +244,13 @@ geodewdt_probe(struct platform_device *dev)
        return ret;
 }
 
-static int __devexit
-geodewdt_remove(struct platform_device *dev)
+static int __devexit geodewdt_remove(struct platform_device *dev)
 {
        misc_deregister(&geodewdt_miscdev);
        return 0;
 }
 
-static void
-geodewdt_shutdown(struct platform_device *dev)
+static void geodewdt_shutdown(struct platform_device *dev)
 {
        geodewdt_disable();
 }
@@ -272,8 +265,7 @@ static struct platform_driver geodewdt_driver = {
        },
 };
 
-static int __init
-geodewdt_init(void)
+static int __init geodewdt_init(void)
 {
        int ret;
 
@@ -281,7 +273,8 @@ geodewdt_init(void)
        if (ret)
                return ret;
 
-       geodewdt_platform_device = platform_device_register_simple(DRV_NAME, -1, NULL, 0);
+       geodewdt_platform_device = platform_device_register_simple(DRV_NAME,
+                                                               -1, NULL, 0);
        if (IS_ERR(geodewdt_platform_device)) {
                ret = PTR_ERR(geodewdt_platform_device);
                goto err;
@@ -293,8 +286,7 @@ err:
        return ret;
 }
 
-static void __exit
-geodewdt_exit(void)
+static void __exit geodewdt_exit(void)
 {
        platform_device_unregister(geodewdt_platform_device);
        platform_driver_unregister(&geodewdt_driver);