From 80ff3f33dbe0f4d6f68053a1b1e188c702c3861e Mon Sep 17 00:00:00 2001 From: H Hartley Sweeten Date: Wed, 19 Dec 2012 15:45:12 -0700 Subject: [PATCH] --- yaml --- r: 353947 b: refs/heads/master c: a52840a98bbb50a7ed881b6cc361957c58c2731d h: refs/heads/master i: 353945: a23b14d26261f29a5743487b1aa330310382379c 353943: 0858e0bace4be228539fea62a980112c5864a3ab v: v3 --- [refs] | 2 +- trunk/drivers/staging/comedi/comedi_fops.c | 29 +++++++++++----------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/[refs] b/[refs] index 8ea7fa285b75..d369635cef0e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 401d99de5c0b70f7d64a410ed01d19032698656c +refs/heads/master: a52840a98bbb50a7ed881b6cc361957c58c2731d diff --git a/trunk/drivers/staging/comedi/comedi_fops.c b/trunk/drivers/staging/comedi/comedi_fops.c index 8d407ccd4ed4..2826a29479c2 100644 --- a/trunk/drivers/staging/comedi/comedi_fops.c +++ b/trunk/drivers/staging/comedi/comedi_fops.c @@ -1766,39 +1766,38 @@ static struct vm_operations_struct comedi_vm_ops = { static int comedi_mmap(struct file *file, struct vm_area_struct *vma) { const unsigned minor = iminor(file->f_dentry->d_inode); - struct comedi_async *async = NULL; + struct comedi_file_info *info = comedi_file_info_from_minor(minor); + struct comedi_device *dev = comedi_dev_from_minor(minor); + struct comedi_subdevice *s; + struct comedi_async *async; unsigned long start = vma->vm_start; unsigned long size; int n_pages; int i; int retval; - struct comedi_subdevice *s; - struct comedi_file_info *info = comedi_file_info_from_minor(minor); - struct comedi_device *dev; - if (info == NULL) - return -ENODEV; - dev = info->device; - if (dev == NULL) + if (!dev) return -ENODEV; mutex_lock(&dev->mutex); + if (!dev->attached) { DPRINTK("no driver configured on comedi%i\n", dev->minor); retval = -ENODEV; goto done; } + if (vma->vm_flags & VM_WRITE) s = comedi_write_subdevice(info); else s = comedi_read_subdevice(info); - - if (s == NULL) { + if (!s) { retval = -EINVAL; goto done; } + async = s->async; - if (async == NULL) { + if (!async) { retval = -EINVAL; goto done; } @@ -1821,11 +1820,11 @@ static int comedi_mmap(struct file *file, struct vm_area_struct *vma) n_pages = size >> PAGE_SHIFT; for (i = 0; i < n_pages; ++i) { + struct comedi_buf_page *buf = &async->buf_page_list[i]; + if (remap_pfn_range(vma, start, - page_to_pfn(virt_to_page - (async->buf_page_list - [i].virt_addr)), PAGE_SIZE, - PAGE_SHARED)) { + page_to_pfn(virt_to_page(buf->virt_addr)), + PAGE_SIZE, PAGE_SHARED)) { retval = -EAGAIN; goto done; }