ipheth: potential null dereferences on error path
[safe/jmp/linux-2.6] / drivers / watchdog / ks8695_wdt.c
index 6d052b8..2852bb2 100644 (file)
@@ -21,8 +21,8 @@
 #include <linux/watchdog.h>
 #include <linux/io.h>
 #include <linux/uaccess.h>
-#include <asm/arch/regs-timer.h>
-
+#include <mach/timex.h>
+#include <mach/regs-timer.h>
 
 #define WDT_DEFAULT_TIME       5       /* seconds */
 #define WDT_MAX_TIME           171     /* seconds */
@@ -66,7 +66,7 @@ static inline void ks8695_wdt_stop(void)
 static inline void ks8695_wdt_start(void)
 {
        unsigned long tmcon;
-       unsigned long tval = wdt_time * CLOCK_TICK_RATE;
+       unsigned long tval = wdt_time * KS8695_CLOCK_RATE;
 
        spin_lock(&ks8695_lock);
        /* disable timer0 */
@@ -103,7 +103,7 @@ static inline void ks8695_wdt_reload(void)
 static int ks8695_wdt_settimeout(int new_time)
 {
        /*
-        * All counting occurs at SLOW_CLOCK / 128 = 0.256 Hz
+        * All counting occurs at KS8695_CLOCK_RATE / 128 = 0.256 Hz
         *
         * Since WDV is a 16-bit counter, the maximum period is
         * 65536 / 0.256 = 256 seconds.
@@ -145,7 +145,7 @@ static int ks8695_wdt_close(struct inode *inode, struct file *file)
        return 0;
 }
 
-static struct watchdog_info ks8695_wdt_info = {
+static const struct watchdog_info ks8695_wdt_info = {
        .identity       = "ks8695 watchdog",
        .options        = WDIOF_SETTIMEOUT | WDIOF_KEEPALIVEPING,
 };
@@ -161,23 +161,9 @@ static long ks8695_wdt_ioctl(struct file *file, unsigned int cmd,
        int new_value;
 
        switch (cmd) {
-       case WDIOC_KEEPALIVE:
-               ks8695_wdt_reload();    /* pat the watchdog */
-               return 0;
        case WDIOC_GETSUPPORT:
                return copy_to_user(argp, &ks8695_wdt_info,
                                        sizeof(ks8695_wdt_info)) ? -EFAULT : 0;
-       case WDIOC_SETTIMEOUT:
-               if (get_user(new_value, p))
-                       return -EFAULT;
-               if (ks8695_wdt_settimeout(new_value))
-                       return -EINVAL;
-               /* Enable new time value */
-               ks8695_wdt_start();
-               /* Return current value */
-               return put_user(wdt_time, p);
-       case WDIOC_GETTIMEOUT:
-               return put_user(wdt_time, p);
        case WDIOC_GETSTATUS:
        case WDIOC_GETBOOTSTATUS:
                return put_user(0, p);
@@ -189,6 +175,20 @@ static long ks8695_wdt_ioctl(struct file *file, unsigned int cmd,
                if (new_value & WDIOS_ENABLECARD)
                        ks8695_wdt_start();
                return 0;
+       case WDIOC_KEEPALIVE:
+               ks8695_wdt_reload();    /* pat the watchdog */
+               return 0;
+       case WDIOC_SETTIMEOUT:
+               if (get_user(new_value, p))
+                       return -EFAULT;
+               if (ks8695_wdt_settimeout(new_value))
+                       return -EINVAL;
+               /* Enable new time value */
+               ks8695_wdt_start();
+               /* Return current value */
+               return put_user(wdt_time, p);
+       case WDIOC_GETTIMEOUT:
+               return put_user(wdt_time, p);
        default:
                return -ENOTTY;
        }
@@ -221,7 +221,7 @@ static struct miscdevice ks8695wdt_miscdev = {
        .fops           = &ks8695wdt_fops,
 };
 
-static int __init ks8695wdt_probe(struct platform_device *pdev)
+static int __devinit ks8695wdt_probe(struct platform_device *pdev)
 {
        int res;
 
@@ -238,7 +238,7 @@ static int __init ks8695wdt_probe(struct platform_device *pdev)
        return 0;
 }
 
-static int __exit ks8695wdt_remove(struct platform_device *pdev)
+static int __devexit ks8695wdt_remove(struct platform_device *pdev)
 {
        int res;
 
@@ -276,7 +276,7 @@ static int ks8695wdt_resume(struct platform_device *pdev)
 
 static struct platform_driver ks8695wdt_driver = {
        .probe          = ks8695wdt_probe,
-       .remove         = __exit_p(ks8695wdt_remove),
+       .remove         = __devexit_p(ks8695wdt_remove),
        .shutdown       = ks8695wdt_shutdown,
        .suspend        = ks8695wdt_suspend,
        .resume         = ks8695wdt_resume,
@@ -293,8 +293,8 @@ static int __init ks8695_wdt_init(void)
           if not reset to the default */
        if (ks8695_wdt_settimeout(wdt_time)) {
                ks8695_wdt_settimeout(WDT_DEFAULT_TIME);
-               pr_info("ks8695_wdt: wdt_time value must be 1 <= wdt_time <= %i, using %d\n",
-                                                       wdt_time, WDT_MAX_TIME);
+               pr_info("ks8695_wdt: wdt_time value must be 1 <= wdt_time <= %i"
+                                       ", using %d\n", wdt_time, WDT_MAX_TIME);
        }
        return platform_driver_register(&ks8695wdt_driver);
 }