headers: remove sched.h from interrupt.h
[safe/jmp/linux-2.6] / drivers / char / nwflash.c
index 206cf6f..8c7df5b 100644 (file)
@@ -21,7 +21,6 @@
 #include <linux/mm.h>
 #include <linux/delay.h>
 #include <linux/proc_fs.h>
-#include <linux/sched.h>
 #include <linux/miscdevice.h>
 #include <linux/spinlock.h>
 #include <linux/rwsem.h>
@@ -59,8 +58,6 @@ static volatile unsigned char *FLASH_BASE;
 static int gbFlashSize = KFLASH_SIZE;
 static DEFINE_MUTEX(nwflash_mutex);
 
-extern spinlock_t gpio_lock;
-
 static int get_flash_id(void)
 {
        volatile unsigned int c1, c2;
@@ -123,35 +120,20 @@ static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cm
 static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
                          loff_t *ppos)
 {
-       unsigned long p = *ppos;
-       unsigned int count = size;
-       int ret = 0;
+       ssize_t ret;
 
        if (flashdebug)
-               printk(KERN_DEBUG "flash_read: flash_read: offset=0x%lX, "
-                      "buffer=%p, count=0x%X.\n", p, buf, count);
-
-       if (count)
-               ret = -ENXIO;
+               printk(KERN_DEBUG "flash_read: flash_read: offset=0x%llx, "
+                      "buffer=%p, count=0x%zx.\n", *ppos, buf, size);
+       /*
+        * We now lock against reads and writes. --rmk
+        */
+       if (mutex_lock_interruptible(&nwflash_mutex))
+               return -ERESTARTSYS;
 
-       if (p < gbFlashSize) {
-               if (count > gbFlashSize - p)
-                       count = gbFlashSize - p;
+       ret = simple_read_from_buffer(buf, size, ppos, (void *)FLASH_BASE, gbFlashSize);
+       mutex_unlock(&nwflash_mutex);
 
-               /*
-                * We now lock against reads and writes. --rmk
-                */
-               if (mutex_lock_interruptible(&nwflash_mutex))
-                       return -ERESTARTSYS;
-
-               ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count);
-               if (ret == 0) {
-                       ret = count;
-                       *ppos += count;
-               } else
-                       ret = -EFAULT;
-               mutex_unlock(&nwflash_mutex);
-       }
        return ret;
 }
 
@@ -632,9 +614,9 @@ static void kick_open(void)
         * we want to write a bit pattern XXX1 to Xilinx to enable
         * the write gate, which will be open for about the next 2ms.
         */
-       spin_lock_irqsave(&gpio_lock, flags);
-       cpld_modify(1, 1);
-       spin_unlock_irqrestore(&gpio_lock, flags);
+       spin_lock_irqsave(&nw_gpio_lock, flags);
+       nw_cpld_modify(CPLD_FLASH_WR_ENABLE, CPLD_FLASH_WR_ENABLE);
+       spin_unlock_irqrestore(&nw_gpio_lock, flags);
 
        /*
         * let the ISA bus to catch on...