diff options
author | Haavard Skinnemoen <haavard.skinnemoen@atmel.com> | 2008-07-27 07:54:08 -0400 |
---|---|---|
committer | Haavard Skinnemoen <haavard.skinnemoen@atmel.com> | 2008-07-27 07:54:08 -0400 |
commit | eda3d8f5604860aae1bb9996bb5efc4213778369 (patch) | |
tree | 9d3887d2665bcc5f5abf200758794545c7b2c69b /drivers/char/nwflash.c | |
parent | 87a9f704658a40940e740b1d73d861667e9164d3 (diff) | |
parent | 8be1a6d6c77ab4532e4476fdb8177030ef48b52c (diff) |
Merge commit 'upstream/master'
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 ba012c2bdf7a..f9f72a211292 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 | |||
122 | static ssize_t flash_read(struct file *file, char __user *buf, size_t size, | 122 | static ssize_t flash_read(struct file *file, char __user *buf, size_t size, |
123 | loff_t *ppos) | 123 | loff_t *ppos) |
124 | { | 124 | { |
125 | unsigned long p = *ppos; | 125 | ssize_t ret; |
126 | unsigned int count = size; | ||
127 | int ret = 0; | ||
128 | 126 | ||
129 | if (flashdebug) | 127 | if (flashdebug) |
130 | printk(KERN_DEBUG "flash_read: flash_read: offset=0x%lX, " | 128 | printk(KERN_DEBUG "flash_read: flash_read: offset=0x%lX, " |
131 | "buffer=%p, count=0x%X.\n", p, buf, count); | 129 | "buffer=%p, count=0x%X.\n", p, buf, count); |
130 | /* | ||
131 | * We now lock against reads and writes. --rmk | ||
132 | */ | ||
133 | if (mutex_lock_interruptible(&nwflash_mutex)) | ||
134 | return -ERESTARTSYS; | ||
132 | 135 | ||
133 | if (count) | 136 | ret = simple_read_from_buffer(buf, size, ppos, FLASH_BASE, gbFlashSize); |
134 | ret = -ENXIO; | 137 | mutex_unlock(&nwflash_mutex); |
135 | |||
136 | if (p < gbFlashSize) { | ||
137 | if (count > gbFlashSize - p) | ||
138 | count = gbFlashSize - p; | ||
139 | 138 | ||
140 | /* | ||
141 | * We now lock against reads and writes. --rmk | ||
142 | */ | ||
143 | if (mutex_lock_interruptible(&nwflash_mutex)) | ||
144 | return -ERESTARTSYS; | ||
145 | |||
146 | ret = copy_to_user(buf, (void *)(FLASH_BASE + p), count); | ||
147 | if (ret == 0) { | ||
148 | ret = count; | ||
149 | *ppos += count; | ||
150 | } else | ||
151 | ret = -EFAULT; | ||
152 | mutex_unlock(&nwflash_mutex); | ||
153 | } | ||
154 | return ret; | 139 | return ret; |
155 | } | 140 | } |
156 | 141 | ||