diff options
-rw-r--r-- | drivers/staging/android/ashmem.c | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/drivers/staging/android/ashmem.c b/drivers/staging/android/ashmem.c index 40c3dc867bf9..777e2b257d4e 100644 --- a/drivers/staging/android/ashmem.c +++ b/drivers/staging/android/ashmem.c | |||
@@ -178,7 +178,7 @@ static int ashmem_open(struct inode *inode, struct file *file) | |||
178 | struct ashmem_area *asma; | 178 | struct ashmem_area *asma; |
179 | int ret; | 179 | int ret; |
180 | 180 | ||
181 | ret = nonseekable_open(inode, file); | 181 | ret = generic_file_open(inode, file); |
182 | if (unlikely(ret)) | 182 | if (unlikely(ret)) |
183 | return ret; | 183 | return ret; |
184 | 184 | ||
@@ -230,6 +230,42 @@ static ssize_t ashmem_read(struct file *file, char __user *buf, | |||
230 | } | 230 | } |
231 | 231 | ||
232 | ret = asma->file->f_op->read(asma->file, buf, len, pos); | 232 | ret = asma->file->f_op->read(asma->file, buf, len, pos); |
233 | if (ret < 0) { | ||
234 | goto out; | ||
235 | } | ||
236 | |||
237 | /** Update backing file pos, since f_ops->read() doesn't */ | ||
238 | asma->file->f_pos = *pos; | ||
239 | |||
240 | out: | ||
241 | mutex_unlock(&ashmem_mutex); | ||
242 | return ret; | ||
243 | } | ||
244 | |||
245 | static loff_t ashmem_llseek(struct file *file, loff_t offset, int origin) | ||
246 | { | ||
247 | struct ashmem_area *asma = file->private_data; | ||
248 | int ret; | ||
249 | |||
250 | mutex_lock(&ashmem_mutex); | ||
251 | |||
252 | if (asma->size == 0) { | ||
253 | ret = -EINVAL; | ||
254 | goto out; | ||
255 | } | ||
256 | |||
257 | if (!asma->file) { | ||
258 | ret = -EBADF; | ||
259 | goto out; | ||
260 | } | ||
261 | |||
262 | ret = asma->file->f_op->llseek(asma->file, offset, origin); | ||
263 | if (ret < 0) { | ||
264 | goto out; | ||
265 | } | ||
266 | |||
267 | /** Copy f_pos from backing file, since f_ops->llseek() sets it */ | ||
268 | file->f_pos = asma->file->f_pos; | ||
233 | 269 | ||
234 | out: | 270 | out: |
235 | mutex_unlock(&ashmem_mutex); | 271 | mutex_unlock(&ashmem_mutex); |
@@ -648,6 +684,7 @@ static struct file_operations ashmem_fops = { | |||
648 | .open = ashmem_open, | 684 | .open = ashmem_open, |
649 | .release = ashmem_release, | 685 | .release = ashmem_release, |
650 | .read = ashmem_read, | 686 | .read = ashmem_read, |
687 | .llseek = ashmem_llseek, | ||
651 | .mmap = ashmem_mmap, | 688 | .mmap = ashmem_mmap, |
652 | .unlocked_ioctl = ashmem_ioctl, | 689 | .unlocked_ioctl = ashmem_ioctl, |
653 | .compat_ioctl = ashmem_ioctl, | 690 | .compat_ioctl = ashmem_ioctl, |