提交 3639c861 编写于 作者: S Sascha Sommer 提交者: Linus Torvalds

[PATCH] V4L/DVB: (3113) Convert em28xx to use vm_insert_page instead of remap_pfn_range

Convert em28xx to use vm_insert_page instead of remap_pfn_range
Signed-off-by: NSascha Sommer <saschasommer@freenet.de>
Signed-off-by: NMichael Krufky <mkrufky@gmail.com>
Signed-off-by: NMauro Carvalho Chehab <mchehab@brturbo.com.br>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: NAndrew Morton <akpm@osdl.org>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 225a0cb6
...@@ -116,48 +116,6 @@ void em28xx_print_ioctl(char *name, unsigned int cmd) ...@@ -116,48 +116,6 @@ void em28xx_print_ioctl(char *name, unsigned int cmd)
} }
} }
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);
}
/* /*
* em28xx_request_buffers() * em28xx_request_buffers()
...@@ -174,8 +132,10 @@ u32 em28xx_request_buffers(struct em28xx *dev, u32 count) ...@@ -174,8 +132,10 @@ u32 em28xx_request_buffers(struct em28xx *dev, u32 count)
dev->num_frames = count; dev->num_frames = count;
while (dev->num_frames > 0) { while (dev->num_frames > 0) {
if ((buff = rvmalloc(dev->num_frames * imagesize))) if ((buff = vmalloc_32(dev->num_frames * imagesize))) {
memset(buff, 0, dev->num_frames * imagesize);
break; break;
}
dev->num_frames--; dev->num_frames--;
} }
...@@ -218,8 +178,7 @@ void em28xx_queue_unusedframes(struct em28xx *dev) ...@@ -218,8 +178,7 @@ void em28xx_queue_unusedframes(struct em28xx *dev)
void em28xx_release_buffers(struct em28xx *dev) void em28xx_release_buffers(struct em28xx *dev)
{ {
if (dev->num_frames) { if (dev->num_frames) {
rvfree(dev->frame[0].bufmem, vfree(dev->frame[0].bufmem);
dev->num_frames * PAGE_ALIGN(dev->frame[0].buf.length));
dev->num_frames = 0; dev->num_frames = 0;
} }
} }
......
...@@ -189,16 +189,6 @@ static DECLARE_RWSEM(em28xx_disconnect); ...@@ -189,16 +189,6 @@ static DECLARE_RWSEM(em28xx_disconnect);
/********************* v4l2 interface ******************************************/ /********************* v4l2 interface ******************************************/
static inline unsigned long kvirt_to_pa(unsigned long adr)
{
unsigned long kva, ret;
kva = (unsigned long)page_address(vmalloc_to_page((void *)adr));
kva |= adr & (PAGE_SIZE - 1);
ret = __pa(kva);
return ret;
}
/* /*
* em28xx_config() * em28xx_config()
* inits registers with sane defaults * inits registers with sane defaults
...@@ -616,7 +606,8 @@ static struct vm_operations_struct em28xx_vm_ops = { ...@@ -616,7 +606,8 @@ static struct vm_operations_struct em28xx_vm_ops = {
static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
{ {
unsigned long size = vma->vm_end - vma->vm_start, unsigned long size = vma->vm_end - vma->vm_start,
start = vma->vm_start, pos, page; start = vma->vm_start;
void *pos;
u32 i; u32 i;
struct em28xx *dev = filp->private_data; struct em28xx *dev = filp->private_data;
...@@ -657,12 +648,10 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) ...@@ -657,12 +648,10 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
vma->vm_flags |= VM_IO; vma->vm_flags |= VM_IO;
vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */ vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */
pos = (unsigned long)dev->frame[i].bufmem; pos = dev->frame[i].bufmem;
while (size > 0) { /* size is page-aligned */ while (size > 0) { /* size is page-aligned */
page = vmalloc_to_pfn((void *)pos); if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
if (remap_pfn_range(vma, start, page, PAGE_SIZE, em28xx_videodbg("mmap: vm_insert_page failed\n");
vma->vm_page_prot)) {
em28xx_videodbg("mmap: rename page map failed\n");
up(&dev->fileop_lock); up(&dev->fileop_lock);
return -EAGAIN; return -EAGAIN;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册