[PATCH 3/3] [media] tw68: don't assume that pagesize is always 4096

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This code implicitly assumes that pagesize is 4096, but this is
not true on all archs, as the PAGE_SHIFT can be different than
12 on all those architectures: alpha, arc, arm64, cris, frv,
hexagon,ia64, m68k, metag, microblaze, mips, openrisc, parisc,
powerpc, sh, sparc and tile.

The real constrant here seems to be to limit the buffer size to
4MB.

So, fix the code to reflect that, in a way that it will keep
working with differnt values for PAGE_SIZE.

Signed-off-by: Mauro Carvalho Chehab <m.chehab@xxxxxxxxxxx>

diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index 4dd38578cf1b..66658accdca9 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -366,7 +366,7 @@ static int tw68_buffer_pages(int size)
 {
 	size  = PAGE_ALIGN(size);
 	size += PAGE_SIZE; /* for non-page-aligned buffers */
-	size /= 4096;
+	size /= PAGE_SIZE;
 	return size;
 }
 
@@ -376,7 +376,7 @@ static int tw68_buffer_count(unsigned int size, unsigned int count)
 {
 	unsigned int maxcount;
 
-	maxcount = 1024 / tw68_buffer_pages(size);
+	maxcount = (4096 * 1024 / PAGE_SIZE) / tw68_buffer_pages(size);
 	if (count > maxcount)
 		count = maxcount;
 	return count;
-- 
1.9.3

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux