aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2014-09-04 13:26:52 -0300
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-09-08 16:40:16 -0300
commit947b38bb110c90e0bc93e7afe9ab6f007b6799a7 (patch)
treeab0d4a0af53c7a308ac7d2d204cbaec920364b1d /drivers/media/pci
parentf1b6a735328b507810d2436891ee977fb8cd62d7 (diff)
[media] tw68: simplify tw68_buffer_count
The code to calculate the maximum number of buffers allowed in 4 MB is 1) wrong if PAGE_SIZE != 4096 and 2) unnecessarily complex. Fix and simplify the code. Reported-by: Mauro Carvalho Chehab <m.chehab@samsung.com> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/pci')
-rw-r--r--drivers/media/pci/tw68/tw68-video.c11
1 files changed, 1 insertions, 10 deletions
diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index 66fae2345fdd..498ead9a956d 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -361,22 +361,13 @@ int tw68_video_start_dma(struct tw68_dev *dev, struct tw68_buf *buf)
/* ------------------------------------------------------------------ */
-/* nr of (tw68-)pages for the given buffer size */
-static int tw68_buffer_pages(int size)
-{
- size = PAGE_ALIGN(size);
- size += PAGE_SIZE; /* for non-page-aligned buffers */
- size /= 4096;
- return size;
-}
-
/* calc max # of buffers from size (must not exceed the 4MB virtual
* address space per DMA channel) */
static int tw68_buffer_count(unsigned int size, unsigned int count)
{
unsigned int maxcount;
- maxcount = 1024 / tw68_buffer_pages(size);
+ maxcount = (4 * 1024 * 1024) / roundup(size, PAGE_SIZE);
if (count > maxcount)
count = maxcount;
return count;

Privacy Policy