diff options
author | David S. Miller <davem@davemloft.net> | 2010-03-15 23:23:54 (GMT) |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2010-03-15 23:23:54 (GMT) |
commit | 4961e02f1999e1c3468c09b2669c94d7c3ae82a8 (patch) | |
tree | 44c15abb09d7ba5e17a9aba95ee246648b1c1a8a /drivers/staging/vme/devices/vme_user.c | |
parent | d14a0ebda7d3daede1a99c01527affb9ceaa4c22 (diff) | |
parent | a3d3203e4bb40f253b1541e310dc0f9305be7c84 (diff) | |
download | linux-fsl-qoriq-4961e02f1999e1c3468c09b2669c94d7c3ae82a8.tar.xz |
Merge branch 'master' of /home/davem/src/GIT/linux-2.6/
Diffstat (limited to 'drivers/staging/vme/devices/vme_user.c')
-rw-r--r-- | drivers/staging/vme/devices/vme_user.c | 65 |
1 files changed, 57 insertions, 8 deletions
diff --git a/drivers/staging/vme/devices/vme_user.c b/drivers/staging/vme/devices/vme_user.c index e228942..c60c80f 100644 --- a/drivers/staging/vme/devices/vme_user.c +++ b/drivers/staging/vme/devices/vme_user.c @@ -1,8 +1,8 @@ /* * VMEbus User access driver * - * Author: Martyn Welch <martyn.welch@gefanuc.com> - * Copyright 2008 GE Fanuc Intelligent Platforms Embedded Systems, Inc. + * Author: Martyn Welch <martyn.welch@ge.com> + * Copyright 2008 GE Intelligent Platforms Embedded Systems, Inc. * * Based on work by: * Tom Armistead and Ajit Prem @@ -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; } /* @@ -574,8 +605,8 @@ static int __init vme_user_init(void) * in future revisions if that ever becomes necessary. */ if (bus_num > USER_BUS_MAX) { - printk(KERN_ERR "%s: Driver only able to handle %d PIO2 " - "Cards\n", driver_name, USER_BUS_MAX); + printk(KERN_ERR "%s: Driver only able to handle %d buses\n", + driver_name, USER_BUS_MAX); bus_num = USER_BUS_MAX; } @@ -670,8 +701,12 @@ static int __init vme_user_probe(struct device *dev, int cur_bus, int cur_slot) /* Request slave resources and allocate buffers (128kB wide) */ for (i = SLAVE_MINOR; i < (SLAVE_MAX + 1); i++) { /* XXX Need to properly request attributes */ + /* For ca91cx42 bridge there are only two slave windows + * supporting A16 addressing, so we request A24 supported + * by all windows. + */ image[i].resource = vme_slave_request(vme_user_bridge, - VME_A16, VME_SCT); + VME_A24, VME_SCT); if (image[i].resource == NULL) { printk(KERN_WARNING "Unable to allocate slave " "resource\n"); @@ -703,6 +738,14 @@ static int __init vme_user_probe(struct device *dev, int cur_bus, int cur_slot) "resource\n"); goto err_master; } + image[i].size_buf = PCI_BUF_SIZE; + image[i].kern_buf = kmalloc(image[i].size_buf, GFP_KERNEL); + if (image[i].kern_buf == NULL) { + printk(KERN_WARNING "Unable to allocate memory for " + "master window buffers\n"); + err = -ENOMEM; + goto err_master_buf; + } } /* Create sysfs entries - on udev systems this creates the dev files */ @@ -756,6 +799,9 @@ err_sysfs: /* Ensure counter set correcty to unalloc all master windows */ i = MASTER_MAX + 1; +err_master_buf: + for (i = MASTER_MINOR; i < (MASTER_MAX + 1); i++) + kfree(image[i].kern_buf); err_master: while (i > MASTER_MINOR) { i--; @@ -791,6 +837,9 @@ static int __exit vme_user_remove(struct device *dev, int cur_bus, int cur_slot) } class_destroy(vme_user_sysfs_class); + for (i = MASTER_MINOR; i < (MASTER_MAX + 1); i++) + kfree(image[i].kern_buf); + for (i = SLAVE_MINOR; i < (SLAVE_MAX + 1); i++) { vme_slave_set(image[i].resource, 0, 0, 0, 0, VME_A32, 0); vme_slave_free(image[i].resource); @@ -818,7 +867,7 @@ MODULE_PARM_DESC(bus, "Enumeration of VMEbus to which the driver is connected"); module_param_array(bus, int, &bus_num, 0); MODULE_DESCRIPTION("VME User Space Access Driver"); -MODULE_AUTHOR("Martyn Welch <martyn.welch@gefanuc.com"); +MODULE_AUTHOR("Martyn Welch <martyn.welch@ge.com"); MODULE_LICENSE("GPL"); module_init(vme_user_init); |