Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 105984
b: refs/heads/master
c: 6ee8928
h: refs/heads/master
v: v3
  • Loading branch information
Akinobu Mita authored and Linus Torvalds committed Jul 25, 2008
1 parent 9be9cc8 commit f379a78
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 24 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 236b8756a2b6f90498d45b2c36d43e5372f2d4b8
refs/heads/master: 6ee8928d94841aa764aeaf645ad16daff811dc26
31 changes: 8 additions & 23 deletions trunk/drivers/char/nwflash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit f379a78

Please sign in to comment.