Commit 6ee8928d authored by Akinobu Mita's avatar Akinobu Mita Committed by Linus Torvalds

nwflash: use simple_read_from_buffer()

Signed-off-by: default avatarAkinobu Mita <akinobu.mita@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Tim Schmielau <tim@physik3.uni-rostock.de>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 236b8756
...@@ -122,35 +122,20 @@ static int flash_ioctl(struct inode *inodep, struct file *filep, unsigned int cm ...@@ -122,35 +122,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, static ssize_t flash_read(struct file *file, char __user *buf, size_t size,
loff_t *ppos) loff_t *ppos)
{ {
unsigned long p = *ppos; ssize_t ret;
unsigned int count = size;
int ret = 0;
if (flashdebug) if (flashdebug)
printk(KERN_DEBUG "flash_read: flash_read: offset=0x%lX, " printk(KERN_DEBUG "flash_read: flash_read: offset=0x%lX, "
"buffer=%p, count=0x%X.\n", p, buf, count); "buffer=%p, count=0x%X.\n", p, buf, count);
/*
* We now lock against reads and writes. --rmk
*/
if (mutex_lock_interruptible(&nwflash_mutex))
return -ERESTARTSYS;
if (count) ret = simple_read_from_buffer(buf, size, ppos, FLASH_BASE, gbFlashSize);
ret = -ENXIO; mutex_unlock(&nwflash_mutex);
if (p < gbFlashSize) {
if (count > gbFlashSize - p)
count = gbFlashSize - p;
/*
* 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; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment