V4L/DVB (8915): cx18: Increment u8 pointers not void pointers.

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Linux Kernel Mailing List
Date: Monday, October 13, 2008 - 3:10 pm

Gitweb:     http://git.kernel.org/git/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=ac2b97...
Commit:     ac2b97b13e5627127b8e29dc0e1e1d7be03eaae4
Parent:     c641d09c60bfa36c7cf70444f24265090e51f5ce
Author:     Andy Walls <awalls@radix.net>
AuthorDate: Thu Sep 4 13:16:40 2008 -0300
Committer:  Mauro Carvalho Chehab <mchehab@redhat.com>
CommitDate: Sun Oct 12 09:36:58 2008 -0200

    V4L/DVB (8915): cx18: Increment u8 pointers not void pointers.
    
    cx18: Increment u8 pointers not void pointers.  Incrementing void pointers
    is dubious and the real intent in cx18_memcpy_fromio() and cx18_memset_io() is
    to increment by bytes, so use u8 pointers instead.
    
    Signed-off-by: Andy Walls <awalls@radix.net>
    Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
---
 drivers/media/video/cx18/cx18-io.c |   56 +++++++++++++++++++----------------
 1 files changed, 30 insertions(+), 26 deletions(-)

diff --git a/drivers/media/video/cx18/cx18-io.c b/drivers/media/video/cx18/cx18-io.c
index d92f627..5d07b0f 100644
--- a/drivers/media/video/cx18/cx18-io.c
+++ b/drivers/media/video/cx18/cx18-io.c
@@ -27,63 +27,67 @@
 void cx18_memcpy_fromio(struct cx18 *cx, void *to,
 			const void __iomem *from, unsigned int len)
 {
+	const u8 *src = from;
+	u8 *dst = to;
+
 	/* Align reads on the CX23418's addresses */
-	if ((len > 0) && ((unsigned)from & 1)) {
-		*((u8 *)to) = cx18_readb(cx, from);
+	if ((len > 0) && ((unsigned long) src & 1)) {
+		*dst = cx18_readb(cx, src);
 		len--;
-		to++;
-		from++;
+		dst++;
+		src++;
 	}
-	if ((len > 1) && ((unsigned)from & 2)) {
-		*((u16 *)to) = cx18_raw_readw(cx, from);
+	if ((len > 1) && ((unsigned long) src & 2)) {
+		*((u16 *)dst) = cx18_raw_readw(cx, src);
 		len -= 2;
-		to += 2;
-		from += 2;
+		dst += 2;
+		src += 2;
 	}
 	while (len > 3) {
-		*((u32 *)to) = cx18_raw_readl(cx, from);
+		*((u32 *)dst) = cx18_raw_readl(cx, src);
 		len -= 4;
-		to += 4;
-		from += 4;
+		dst += 4;
+		src += 4;
 	}
 	if (len > 1) {
-		*((u16 *)to) = cx18_raw_readw(cx, from);
+		*((u16 *)dst) = cx18_raw_readw(cx, src);
 		len -= 2;
-		to += 2;
-		from += 2;
+		dst += 2;
+		src += 2;
 	}
 	if (len > 0)
-		*((u8 *)to) = cx18_readb(cx, from);
+		*dst = cx18_readb(cx, src);
 }
 
 void cx18_memset_io(struct cx18 *cx, void __iomem *addr, int val, size_t count)
 {
+	u8 *dst = addr;
 	u16 val2 = val | (val << 8);
 	u32 val4 = val2 | (val2 << 16);
 
 	/* Align writes on the CX23418's addresses */
-	if ((count > 0) && ((unsigned)addr & 1)) {
-		cx18_writeb(cx, (u8) val, addr);
+	if ((count > 0) && ((unsigned long)dst & 1)) {
+		cx18_writeb(cx, (u8) val, dst);
 		count--;
-		addr++;
+		dst++;
 	}
-	if ((count > 1) && ((unsigned)addr & 2)) {
-		cx18_writew(cx, val2, addr);
+	if ((count > 1) && ((unsigned long)dst & 2)) {
+		cx18_writew(cx, val2, dst);
 		count -= 2;
-		addr += 2;
+		dst += 2;
 	}
 	while (count > 3) {
-		cx18_writel(cx, val4, addr);
+		cx18_writel(cx, val4, dst);
 		count -= 4;
-		addr += 4;
+		dst += 4;
 	}
 	if (count > 1) {
-		cx18_writew(cx, val2, addr);
+		cx18_writew(cx, val2, dst);
 		count -= 2;
-		addr += 2;
+		dst += 2;
 	}
 	if (count > 0)
-		cx18_writeb(cx, (u8) val, addr);
+		cx18_writeb(cx, (u8) val, dst);
 }
 
 void cx18_sw1_irq_enable(struct cx18 *cx, u32 val)
--
To unsubscribe from this list: send the line "unsubscribe git-commits-head" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
V4L/DVB (8915): cx18: Increment u8 pointers not void pointers., Linux Kernel Mailing ..., (Mon Oct 13, 3:10 pm)