All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] tw68: simplify tw68_buffer_count
@ 2014-09-04 16:26 Hans Verkuil
  2014-09-04 16:26 ` [PATCH 2/2] tw68: drop bogus cpu_to_le32() call Hans Verkuil
  0 siblings, 1 reply; 2+ messages in thread
From: Hans Verkuil @ 2014-09-04 16:26 UTC (permalink / raw
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

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.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/pci/tw68/tw68-video.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index 66fae23..498ead9 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;
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] tw68: drop bogus cpu_to_le32() call
  2014-09-04 16:26 [PATCH 1/2] tw68: simplify tw68_buffer_count Hans Verkuil
@ 2014-09-04 16:26 ` Hans Verkuil
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2014-09-04 16:26 UTC (permalink / raw
  To: linux-media; +Cc: Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

tw_writel maps to writel which maps to __raw_writel(__cpu_to_le32(b),addr).
So tw_writel already calls cpu_to_le32 and it shouldn't be called again
in the code.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/pci/tw68/tw68-video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/pci/tw68/tw68-video.c b/drivers/media/pci/tw68/tw68-video.c
index 498ead9..5c94ac7 100644
--- a/drivers/media/pci/tw68/tw68-video.c
+++ b/drivers/media/pci/tw68/tw68-video.c
@@ -348,7 +348,7 @@ int tw68_video_start_dma(struct tw68_dev *dev, struct tw68_buf *buf)
 	 *  a new address can be set.
 	 */
 	tw_clearl(TW68_DMAC, TW68_DMAP_EN);
-	tw_writel(TW68_DMAP_SA, cpu_to_le32(buf->dma));
+	tw_writel(TW68_DMAP_SA, buf->dma);
 	/* Clear any pending interrupts */
 	tw_writel(TW68_INTSTAT, dev->board_virqmask);
 	/* Enable the risc engine and the fifo */
-- 
2.1.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-09-04 16:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-04 16:26 [PATCH 1/2] tw68: simplify tw68_buffer_count Hans Verkuil
2014-09-04 16:26 ` [PATCH 2/2] tw68: drop bogus cpu_to_le32() call Hans Verkuil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.