> +static void* rvmalloc(size_t size) > +{ > + void* mem; > + unsigned long adr; > + > + size = PAGE_ALIGN(size); > + > + mem = vmalloc_32((unsigned long)size); > + if (!mem) > + return NULL; > + > + memset(mem, 0, size); > + > + adr = (unsigned long)mem; > + while (size > 0) { > + SetPageReserved(vmalloc_to_page((void *)adr)); > + adr += PAGE_SIZE; > + size -= PAGE_SIZE; > + } > + > + return mem; > +} > + > + > +static void rvfree(void* mem, size_t size) > +{ > + unsigned long adr; > + > + if (!mem) > + return; > + > + size = PAGE_ALIGN(size); > + > + adr = (unsigned long)mem; > + while (size > 0) { > + ClearPageReserved(vmalloc_to_page((void *)adr)); > + adr += PAGE_SIZE; > + size -= PAGE_SIZE; > + } > + > + vfree(mem); > +}
Please remove rvmalloc and rvfree. Use vmalloc_32 and vfree directly instead, as vm_insert_page (see below) doesn't require you to mark the pages as reserved. > +static int et61x251_mmap(struct file* filp, struct vm_area_struct *vma) > +{ > + struct et61x251_device* cam = video_get_drvdata(video_devdata(filp)); > + unsigned long size = vma->vm_end - vma->vm_start, > + start = vma->vm_start, > + pos, > + page; > + u32 i; > + > + if (down_interruptible(&cam->fileop_sem)) > + return -ERESTARTSYS; > + > + if (cam->state & DEV_DISCONNECTED) { > + DBG(1, "Device not present"); > + up(&cam->fileop_sem); > + return -ENODEV; > + } > + > + if (cam->state & DEV_MISCONFIGURED) { > + DBG(1, "The camera is misconfigured. Close and open it " > + "again."); > + up(&cam->fileop_sem); > + return -EIO; > + } > + > + if (cam->io != IO_MMAP || !(vma->vm_flags & VM_WRITE) || > + size != PAGE_ALIGN(cam->frame[0].buf.length)) { > + up(&cam->fileop_sem); > + return -EINVAL; > + } > + > + for (i = 0; i < cam->nbuffers; i++) { > + if ((cam->frame[i].buf.m.offset>>PAGE_SHIFT) == vma->vm_pgoff) > + break; > + } > + if (i == cam->nbuffers) { > + up(&cam->fileop_sem); > + return -EINVAL; > + } > + > + /* VM_IO is eventually going to replace PageReserved altogether */ > + vma->vm_flags |= VM_IO; > + vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */ If I'm not mistaken, VM_RESERVED isn't used anymore for that purpose (its only purpose is to count the pages in reserved_vm and prevent the area from being core dumped, and so is redundant with VM_IO). Can anyone confirm ? > + > + pos = (unsigned long)cam->frame[i].bufmem; > + while (size > 0) { /* size is page-aligned */ > + page = vmalloc_to_pfn((void *)pos); > + if (remap_pfn_range(vma, start, page, PAGE_SIZE, > + vma->vm_page_prot)) { Please use vm_insert_page(). > + up(&cam->fileop_sem); > + return -EAGAIN; > + } > + start += PAGE_SIZE; > + pos += PAGE_SIZE; > + size -= PAGE_SIZE; > + } > + > + vma->vm_ops = &et61x251_vm_ops; > + vma->vm_private_data = &cam->frame[i]; > + > + et61x251_vm_open(vma); > + > + up(&cam->fileop_sem); > + > + return 0; > +} Laurent Pinchart ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel