2.6.21 fix lba48 bug in libata fill_result_tf()
[safe/jmp/linux-2.6] / drivers / char / watchdog / booke_wdt.c
index 65830ec..0e23f29 100644 (file)
@@ -14,7 +14,6 @@
  * option) any later version.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/fs.h>
 #include <linux/miscdevice.h>
@@ -36,7 +35,7 @@
 #ifdef CONFIG_FSL_BOOKE
 #define WDT_PERIOD_DEFAULT 63  /* Ex. wdt_period=28 bus=333Mhz , reset=~40sec */
 #else
-#define WDT_PERIOD_DEFAULT 4   /* Refer to the PPC40x and PPC4xx manuals */
+#define WDT_PERIOD_DEFAULT 3   /* Refer to the PPC40x and PPC4xx manuals */
 #endif                         /* for timing information */
 
 u32 booke_wdt_enabled = 0;
@@ -49,12 +48,22 @@ u32 booke_wdt_period = WDT_PERIOD_DEFAULT;
 #endif
 
 /*
+ * booke_wdt_ping:
+ */
+static __inline__ void booke_wdt_ping(void)
+{
+       mtspr(SPRN_TSR, TSR_ENW|TSR_WIS);
+}
+
+/*
  * booke_wdt_enable:
  */
 static __inline__ void booke_wdt_enable(void)
 {
        u32 val;
 
+       /* clear status before enabling watchdog */
+       booke_wdt_ping();
        val = mfspr(SPRN_TCR);
        val |= (TCR_WIE|TCR_WRC(WRC_CHIP)|WDTP(booke_wdt_period));
 
@@ -62,17 +71,9 @@ static __inline__ void booke_wdt_enable(void)
 }
 
 /*
- * booke_wdt_ping:
- */
-static __inline__ void booke_wdt_ping(void)
-{
-       mtspr(SPRN_TSR, TSR_ENW|TSR_WIS);
-}
-
-/*
  * booke_wdt_write:
  */
-static ssize_t booke_wdt_write (struct file *file, const char *buf,
+static ssize_t booke_wdt_write (struct file *file, const char __user *buf,
                                size_t count, loff_t *ppos)
 {
        booke_wdt_ping();
@@ -92,14 +93,15 @@ static int booke_wdt_ioctl (struct inode *inode, struct file *file,
                            unsigned int cmd, unsigned long arg)
 {
        u32 tmp = 0;
+       u32 __user *p = (u32 __user *)arg;
 
        switch (cmd) {
        case WDIOC_GETSUPPORT:
-               if (copy_to_user ((struct watchdog_info *) arg, &ident,
+               if (copy_to_user ((struct watchdog_info __user *) arg, &ident,
                                sizeof(struct watchdog_info)))
                        return -EFAULT;
        case WDIOC_GETSTATUS:
-               return put_user(ident.options, (u32 *) arg);
+               return put_user(ident.options, p);
        case WDIOC_GETBOOTSTATUS:
                /* XXX: something is clearing TSR */
                tmp = mfspr(SPRN_TSR) & TSR_WRS(3);
@@ -109,14 +111,14 @@ static int booke_wdt_ioctl (struct inode *inode, struct file *file,
                booke_wdt_ping();
                return 0;
        case WDIOC_SETTIMEOUT:
-               if (get_user(booke_wdt_period, (u32 *) arg))
+               if (get_user(booke_wdt_period, p))
                        return -EFAULT;
                mtspr(SPRN_TCR, (mfspr(SPRN_TCR)&~WDTP(0))|WDTP(booke_wdt_period));
                return 0;
        case WDIOC_GETTIMEOUT:
-               return put_user(booke_wdt_period, (u32 *) arg);
+               return put_user(booke_wdt_period, p);
        case WDIOC_SETOPTIONS:
-               if (get_user(tmp, (u32 *) arg))
+               if (get_user(tmp, p))
                        return -EINVAL;
                if (tmp == WDIOS_ENABLECARD) {
                        booke_wdt_ping();
@@ -125,7 +127,7 @@ static int booke_wdt_ioctl (struct inode *inode, struct file *file,
                        return -EINVAL;
                return 0;
        default:
-               return -ENOIOCTLCMD;
+               return -ENOTTY;
        }
 
        return 0;
@@ -145,7 +147,7 @@ static int booke_wdt_open (struct inode *inode, struct file *file)
        return 0;
 }
 
-static struct file_operations booke_wdt_fops = {
+static const struct file_operations booke_wdt_fops = {
   .owner = THIS_MODULE,
   .llseek = no_llseek,
   .write = booke_wdt_write,
@@ -172,7 +174,7 @@ static int __init booke_wdt_init(void)
        int ret = 0;
 
        printk (KERN_INFO "PowerPC Book-E Watchdog Timer Loaded\n");
-       ident.firmware_version = cpu_specs[0].pvr_value;
+       ident.firmware_version = cur_cpu_spec->pvr_value;
 
        ret = misc_register(&booke_wdt_miscdev);
        if (ret) {