diff options
author | Arthur Benilov <arthur.benilov@iba-group.com> | 2010-02-16 15:40:30 +0100 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-03-03 16:43:01 -0800 |
commit | 877de4b4866f1cc0a25a4d67d3927304556f5d1f (patch) | |
tree | 056201833a55a23a37d1fb894942441a1c2fc49c /drivers/staging/vme | |
parent | bb9ea89ec8a3d80a835d53afc388ad5f67fd3cb3 (diff) | |
download | blackbird-op-linux-877de4b4866f1cc0a25a4d67d3927304556f5d1f.tar.gz blackbird-op-linux-877de4b4866f1cc0a25a4d67d3927304556f5d1f.zip |
Staging: vme: llseek support in user driver
Provide vme_user_llseek() implementation.
Signed-off-by: Arthur Benilov <arthur.benilov@iba-group.com>
Signed-off-by: Vincent Bossier <vincent.bossier@iba-group.com>
Acked-by: Martyn Welch <martyn.welch@ge.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/vme')
-rw-r--r-- | drivers/staging/vme/devices/vme_user.c | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index 48d46cadb13f..ddecbe5105b9 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -400,8 +400,39 @@ static ssize_t vme_user_write(struct file *file, const char *buf, size_t count, static loff_t vme_user_llseek(struct file *file, loff_t off, int whence) { - printk(KERN_ERR "Llseek currently incomplete\n"); - return -EINVAL; + loff_t absolute = -1; + unsigned int minor = MINOR(file->f_dentry->d_inode->i_rdev); + size_t image_size; + + down(&image[minor].sem); + image_size = vme_get_size(image[minor].resource); + + switch (whence) { + case SEEK_SET: + absolute = off; + break; + case SEEK_CUR: + absolute = file->f_pos + off; + break; + case SEEK_END: + absolute = image_size + off; + break; + default: + up(&image[minor].sem); + return -EINVAL; + break; + } + + if ((absolute < 0) || (absolute >= image_size)) { + up(&image[minor].sem); + return -EINVAL; + } + + file->f_pos = absolute; + + up(&image[minor].sem); + + return absolute; } /* |