diff options
author | Akinobu Mita <akinobu.mita@gmail.com> | 2008-07-25 01:48:18 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-07-25 10:53:43 -0700 |
commit | 6ee8928d94841aa764aeaf645ad16daff811dc26 (patch) | |
tree | 04570a3c34e5589e910412f2850fa1b2345eafa2 /drivers/char/nwflash.c | |
parent | 236b8756a2b6f90498d45b2c36d43e5372f2d4b8 (diff) | |
download | linux-3.10-6ee8928d94841aa764aeaf645ad16daff811dc26.tar.gz linux-3.10-6ee8928d94841aa764aeaf645ad16daff811dc26.tar.bz2 linux-3.10-6ee8928d94841aa764aeaf645ad16daff811dc26.zip |
nwflash: use simple_read_from_buffer()
Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Russell King <linux@arm.linux.org.uk>
Cc: Tim Schmielau <tim@physik3.uni-rostock.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/nwflash.c')
-rw-r--r-- | drivers/char/nwflash.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/drivers/char/nwflash.c b/drivers/char/nwflash.c index ba012c2bdf7..f9f72a21129 100644 --- a/drivers/char/nwflash.c +++ b/drivers/char/nwflash.c @@ -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, 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); + /* + * We now lock against reads and writes. --rmk + */ + if (mutex_lock_interruptible(&nwflash_mutex)) + return -ERESTARTSYS; - if (count) - ret = -ENXIO; - - if (p < gbFlashSize) { - if (count > gbFlashSize - p) - count = gbFlashSize - p; + ret = simple_read_from_buffer(buf, size, ppos, 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; } |