Revert to Fedora kernel-2.6.17-1.2187_FC5 patched with vs2.0.2.1; there are too many...
[linux-2.6.git] / drivers / char / nwflash.c
index e75381e..8865387 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/rwsem.h>
 #include <linux/init.h>
 #include <linux/smp_lock.h>
+#include <linux/mutex.h>
 
 #include <asm/hardware/dec21285.h>
 #include <asm/io.h>
@@ -56,19 +57,10 @@ static int gbWriteEnable;
 static int gbWriteBase64Enable;
 static volatile unsigned char *FLASH_BASE;
 static int gbFlashSize = KFLASH_SIZE;
-static DECLARE_MUTEX(nwflash_sem);
+static DEFINE_MUTEX(nwflash_mutex);
 
 extern spinlock_t gpio_lock;
 
-/*
- * the delay routine - it is often required to let the flash "breeze"...
- */
-void flash_wait(int timeout)
-{
-       current->state = TASK_INTERRUPTIBLE;
-       schedule_timeout(timeout);
-}
-
 static int get_flash_id(void)
 {
        volatile unsigned int c1, c2;
@@ -149,7 +141,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
                /*
                 * We now lock against reads and writes. --rmk
                 */
-               if (down_interruptible(&nwflash_sem))
+               if (mutex_lock_interruptible(&nwflash_mutex))
                        return -ERESTARTSYS;
 
                ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count);
@@ -158,7 +150,7 @@ static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
                        *ppos += count;
                } else
                        ret = -EFAULT;
-               up(&nwflash_sem);
+               mutex_unlock(&nwflash_mutex);
        }
        return ret;
 }
@@ -191,13 +183,13 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
        if (count > gbFlashSize - p)
                count = gbFlashSize - p;
                        
-       if (verify_area(VERIFY_READ, buf, count))
+       if (!access_ok(VERIFY_READ, buf, count))
                return -EFAULT;
 
        /*
         * We now lock against reads and writes. --rmk
         */
-       if (down_interruptible(&nwflash_sem))
+       if (mutex_lock_interruptible(&nwflash_mutex))
                return -ERESTARTSYS;
 
        written = 0;
@@ -286,7 +278,7 @@ static ssize_t flash_write(struct file *file, const char __user *buf,
         */
        leds_event(led_release);
 
-       up(&nwflash_sem);
+       mutex_unlock(&nwflash_mutex);
 
        return written;
 }
@@ -401,7 +393,7 @@ static int erase_block(int nBlock)
        /*
         * wait 10 ms
         */
-       flash_wait(HZ / 100);
+       msleep(10);
 
        /*
         * wait while erasing in process (up to 10 sec)
@@ -409,7 +401,7 @@ static int erase_block(int nBlock)
        timeout = jiffies + 10 * HZ;
        c1 = 0;
        while (!(c1 & 0x80) && time_before(jiffies, timeout)) {
-               flash_wait(HZ / 100);
+               msleep(10);
                /*
                 * read any address
                 */
@@ -440,7 +432,7 @@ static int erase_block(int nBlock)
        /*
         * just to make sure - verify if erased OK...
         */
-       flash_wait(HZ / 100);
+       msleep(10);
 
        pWritePtr = (unsigned char *) ((unsigned int) (FLASH_BASE + (nBlock << 16)));
 
@@ -587,7 +579,7 @@ static int write_block(unsigned long p, const char __user *buf, int count)
                                /*
                                 * wait couple ms
                                 */
-                               flash_wait(HZ / 100);
+                               msleep(10);
                                /*
                                 * red LED == write
                                 */
@@ -612,7 +604,7 @@ static int write_block(unsigned long p, const char __user *buf, int count)
        leds_event(led_amber_off);
        leds_event(led_green_on);
 
-       flash_wait(HZ / 100);
+       msleep(10);
 
        pWritePtr = (unsigned char *) ((unsigned int) (FLASH_BASE + p));
 
@@ -705,7 +697,7 @@ static void __exit nwflash_exit(void)
 
 MODULE_LICENSE("GPL");
 
-MODULE_PARM(flashdebug, "i");
+module_param(flashdebug, bool, 0644);
 
 module_init(nwflash_init);
 module_exit(nwflash_exit);