#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>
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;
/*
* 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);
*ppos += count;
} else
ret = -EFAULT;
- up(&nwflash_sem);
+ mutex_unlock(&nwflash_mutex);
}
return ret;
}
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;
*/
leds_event(led_release);
- up(&nwflash_sem);
+ mutex_unlock(&nwflash_mutex);
return written;
}
/*
* wait 10 ms
*/
- flash_wait(HZ / 100);
+ msleep(10);
/*
* wait while erasing in process (up to 10 sec)
timeout = jiffies + 10 * HZ;
c1 = 0;
while (!(c1 & 0x80) && time_before(jiffies, timeout)) {
- flash_wait(HZ / 100);
+ msleep(10);
/*
* read any address
*/
/*
* just to make sure - verify if erased OK...
*/
- flash_wait(HZ / 100);
+ msleep(10);
pWritePtr = (unsigned char *) ((unsigned int) (FLASH_BASE + (nBlock << 16)));
/*
* wait couple ms
*/
- flash_wait(HZ / 100);
+ msleep(10);
/*
* red LED == write
*/
leds_event(led_amber_off);
leds_event(led_green_on);
- flash_wait(HZ / 100);
+ msleep(10);
pWritePtr = (unsigned char *) ((unsigned int) (FLASH_BASE + p));
MODULE_LICENSE("GPL");
-MODULE_PARM(flashdebug, "i");
+module_param(flashdebug, bool, 0644);
module_init(nwflash_init);
module_exit(nwflash_exit);