aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Sommer <saschasommer@freenet.de>2005-12-12 03:37:30 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2005-12-12 11:57:44 -0500
commit3639c8619d50a6dea8fa106a5c61d848ffdcd3d6 (patch)
treef2ec8303fee79b26097ba996941a6550ffac7dbc
parent225a0cb6716da3aafaeb9ed2f8d9a7a1f2af9f09 (diff)
[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: Sascha Sommer <saschasommer@freenet.de> Signed-off-by: Michael Krufky <mkrufky@gmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br> Cc: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/media/video/em28xx/em28xx-core.c49
-rw-r--r--drivers/media/video/em28xx/em28xx-video.c21
2 files changed, 9 insertions, 61 deletions
diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c
index 517573221972..e8a1c2247567 100644
--- a/drivers/media/video/em28xx/em28xx-core.c
+++ b/drivers/media/video/em28xx/em28xx-core.c
@@ -116,48 +116,6 @@ void em28xx_print_ioctl(char *name, unsigned int cmd)
116 } 116 }
117} 117}
118 118
119static void *rvmalloc(size_t size)
120{
121 void *mem;
122 unsigned long adr;
123
124 size = PAGE_ALIGN(size);
125
126 mem = vmalloc_32((unsigned long)size);
127 if (!mem)
128 return NULL;
129
130 memset(mem, 0, size);
131
132 adr = (unsigned long)mem;
133 while (size > 0) {
134 SetPageReserved(vmalloc_to_page((void *)adr));
135 adr += PAGE_SIZE;
136 size -= PAGE_SIZE;
137 }
138
139 return mem;
140}
141
142static void rvfree(void *mem, size_t size)
143{
144 unsigned long adr;
145
146 if (!mem)
147 return;
148
149 size = PAGE_ALIGN(size);
150
151 adr = (unsigned long)mem;
152 while (size > 0) {
153 ClearPageReserved(vmalloc_to_page((void *)adr));
154 adr += PAGE_SIZE;
155 size -= PAGE_SIZE;
156 }
157
158 vfree(mem);
159}
160
161 119
162/* 120/*
163 * em28xx_request_buffers() 121 * em28xx_request_buffers()
@@ -174,8 +132,10 @@ u32 em28xx_request_buffers(struct em28xx *dev, u32 count)
174 132
175 dev->num_frames = count; 133 dev->num_frames = count;
176 while (dev->num_frames > 0) { 134 while (dev->num_frames > 0) {
177 if ((buff = rvmalloc(dev->num_frames * imagesize))) 135 if ((buff = vmalloc_32(dev->num_frames * imagesize))) {
136 memset(buff, 0, dev->num_frames * imagesize);
178 break; 137 break;
138 }
179 dev->num_frames--; 139 dev->num_frames--;
180 } 140 }
181 141
@@ -218,8 +178,7 @@ void em28xx_queue_unusedframes(struct em28xx *dev)
218void em28xx_release_buffers(struct em28xx *dev) 178void em28xx_release_buffers(struct em28xx *dev)
219{ 179{
220 if (dev->num_frames) { 180 if (dev->num_frames) {
221 rvfree(dev->frame[0].bufmem, 181 vfree(dev->frame[0].bufmem);
222 dev->num_frames * PAGE_ALIGN(dev->frame[0].buf.length));
223 dev->num_frames = 0; 182 dev->num_frames = 0;
224 } 183 }
225} 184}
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index c08e505e7009..8ecaa0803e08 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -189,16 +189,6 @@ static DECLARE_RWSEM(em28xx_disconnect);
189 189
190/********************* v4l2 interface ******************************************/ 190/********************* v4l2 interface ******************************************/
191 191
192static inline unsigned long kvirt_to_pa(unsigned long adr)
193{
194 unsigned long kva, ret;
195
196 kva = (unsigned long)page_address(vmalloc_to_page((void *)adr));
197 kva |= adr & (PAGE_SIZE - 1);
198 ret = __pa(kva);
199 return ret;
200}
201
202/* 192/*
203 * em28xx_config() 193 * em28xx_config()
204 * inits registers with sane defaults 194 * inits registers with sane defaults
@@ -616,7 +606,8 @@ static struct vm_operations_struct em28xx_vm_ops = {
616static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma) 606static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
617{ 607{
618 unsigned long size = vma->vm_end - vma->vm_start, 608 unsigned long size = vma->vm_end - vma->vm_start,
619 start = vma->vm_start, pos, page; 609 start = vma->vm_start;
610 void *pos;
620 u32 i; 611 u32 i;
621 612
622 struct em28xx *dev = filp->private_data; 613 struct em28xx *dev = filp->private_data;
@@ -657,12 +648,10 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
657 vma->vm_flags |= VM_IO; 648 vma->vm_flags |= VM_IO;
658 vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */ 649 vma->vm_flags |= VM_RESERVED; /* avoid to swap out this VMA */
659 650
660 pos = (unsigned long)dev->frame[i].bufmem; 651 pos = dev->frame[i].bufmem;
661 while (size > 0) { /* size is page-aligned */ 652 while (size > 0) { /* size is page-aligned */
662 page = vmalloc_to_pfn((void *)pos); 653 if (vm_insert_page(vma, start, vmalloc_to_page(pos))) {
663 if (remap_pfn_range(vma, start, page, PAGE_SIZE, 654 em28xx_videodbg("mmap: vm_insert_page failed\n");
664 vma->vm_page_prot)) {
665 em28xx_videodbg("mmap: rename page map failed\n");
666 up(&dev->fileop_lock); 655 up(&dev->fileop_lock);
667 return -EAGAIN; 656 return -EAGAIN;
668 } 657 }