From a9b12619f7b6f19c871437ec24a088787a04b1de Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Mon, 21 Jul 2008 20:03:34 -0700 Subject: device create: misc: convert device_create_drvdata to device_create Now that device_create() has been audited, rename things back to the original call to be sane. Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/uio/uio.c') diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 3a6934bf713..9ac22c7c385 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -682,9 +682,9 @@ int __uio_register_device(struct module *owner, if (ret) goto err_get_minor; - idev->dev = device_create_drvdata(uio_class->class, parent, - MKDEV(uio_major, idev->minor), idev, - "uio%d", idev->minor); + idev->dev = device_create(uio_class->class, parent, + MKDEV(uio_major, idev->minor), idev, + "uio%d", idev->minor); if (IS_ERR(idev->dev)) { printk(KERN_ERR "UIO: device register failed\n"); ret = PTR_ERR(idev->dev); -- cgit v1.2.3 From e2b39df119712ea5184562a6a14696a5cea8ef18 Mon Sep 17 00:00:00 2001 From: "Hans J. Koch" Date: Thu, 18 Sep 2008 23:53:18 +0200 Subject: UIO: Add alignment warnings for uio-mem This patch adds an "offset" attribute for UIO mappings. It shows the difference between the actual start address of the memory and the start address of the page. Signed-off-by: Hans J. Koch Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'drivers/uio/uio.c') diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 9ac22c7c385..557e73ef588 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -67,6 +67,11 @@ static ssize_t map_size_show(struct uio_mem *mem, char *buf) return sprintf(buf, "0x%lx\n", mem->size); } +static ssize_t map_offset_show(struct uio_mem *mem, char *buf) +{ + return sprintf(buf, "0x%lx\n", mem->addr & ~PAGE_MASK); +} + struct uio_sysfs_entry { struct attribute attr; ssize_t (*show)(struct uio_mem *, char *); @@ -77,10 +82,13 @@ static struct uio_sysfs_entry addr_attribute = __ATTR(addr, S_IRUGO, map_addr_show, NULL); static struct uio_sysfs_entry size_attribute = __ATTR(size, S_IRUGO, map_size_show, NULL); +static struct uio_sysfs_entry offset_attribute = + __ATTR(offset, S_IRUGO, map_offset_show, NULL); static struct attribute *attrs[] = { &addr_attribute.attr, &size_attribute.attr, + &offset_attribute.attr, NULL, /* need to NULL terminate the list of attributes */ }; -- cgit v1.2.3 From 02683ffdf655b4ae15245376ba6fea6d9e5829a6 Mon Sep 17 00:00:00 2001 From: "Andrew G. Harvey" Date: Wed, 24 Sep 2008 01:10:02 +0200 Subject: UIO: Fix mapping of logical and virtual memory mmap() doesn't work as expected for UIO_MEM_LOGICAL or UIO_MEM_VIRTUAL mappings. The offset into the memory needs to be added, otherwise uio_vma_fault always returns the first page only. Note that for UIO userspace calls mmap() with offset = N * getpagesize() to access mapping N. This must be compensated when calculating the offset. A comment was added to explain this since it is not obvious. Signed-off-by: Andrew G. Harvey Signed-off-by: Hans J. Koch Signed-off-by: Greg Kroah-Hartman --- drivers/uio/uio.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'drivers/uio/uio.c') diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c index 557e73ef588..5dccf057a7d 100644 --- a/drivers/uio/uio.c +++ b/drivers/uio/uio.c @@ -490,15 +490,23 @@ static int uio_vma_fault(struct vm_area_struct *vma, struct vm_fault *vmf) { struct uio_device *idev = vma->vm_private_data; struct page *page; + unsigned long offset; int mi = uio_find_mem_index(vma); if (mi < 0) return VM_FAULT_SIGBUS; + /* + * We need to subtract mi because userspace uses offset = N*PAGE_SIZE + * to use mem[N]. + */ + offset = (vmf->pgoff - mi) << PAGE_SHIFT; + if (idev->info->mem[mi].memtype == UIO_MEM_LOGICAL) - page = virt_to_page(idev->info->mem[mi].addr); + page = virt_to_page(idev->info->mem[mi].addr + offset); else - page = vmalloc_to_page((void*)idev->info->mem[mi].addr); + page = vmalloc_to_page((void *)idev->info->mem[mi].addr + + offset); get_page(page); vmf->page = page; return 0; -- cgit v1.2.3