~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to drivers/uio/uio.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
381
381
                        retval = -ENOMEM;
382
382
                goto exit;
383
383
        }
384
 
        idev->minor = id & MAX_ID_MASK;
 
384
        if (id < UIO_MAX_DEVICES) {
 
385
                idev->minor = id;
 
386
        } else {
 
387
                dev_err(idev->dev, "too many uio devices\n");
 
388
                retval = -EINVAL;
 
389
                idr_remove(&uio_idr, id);
 
390
        }
385
391
exit:
386
392
        mutex_unlock(&minor_lock);
387
393
        return retval;
587
593
 
588
594
static int uio_find_mem_index(struct vm_area_struct *vma)
589
595
{
590
 
        int mi;
591
596
        struct uio_device *idev = vma->vm_private_data;
592
597
 
593
 
        for (mi = 0; mi < MAX_UIO_MAPS; mi++) {
594
 
                if (idev->info->mem[mi].size == 0)
 
598
        if (vma->vm_pgoff < MAX_UIO_MAPS) {
 
599
                if (idev->info->mem[vma->vm_pgoff].size == 0)
595
600
                        return -1;
596
 
                if (vma->vm_pgoff == mi)
597
 
                        return mi;
 
601
                return (int)vma->vm_pgoff;
598
602
        }
599
603
        return -1;
600
604
}