Commit ac2b97b1 authored by Andy Walls's avatar Andy Walls Committed by Mauro Carvalho Chehab

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: default avatarAndy Walls <awalls@radix.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent c641d09c
...@@ -27,63 +27,67 @@ ...@@ -27,63 +27,67 @@
void cx18_memcpy_fromio(struct cx18 *cx, void *to, void cx18_memcpy_fromio(struct cx18 *cx, void *to,
const void __iomem *from, unsigned int len) const void __iomem *from, unsigned int len)
{ {
const u8 *src = from;
u8 *dst = to;
/* Align reads on the CX23418's addresses */ /* Align reads on the CX23418's addresses */
if ((len > 0) && ((unsigned)from & 1)) { if ((len > 0) && ((unsigned long) src & 1)) {
*((u8 *)to) = cx18_readb(cx, from); *dst = cx18_readb(cx, src);
len--; len--;
to++; dst++;
from++; src++;
} }
if ((len > 1) && ((unsigned)from & 2)) { if ((len > 1) && ((unsigned long) src & 2)) {
*((u16 *)to) = cx18_raw_readw(cx, from); *((u16 *)dst) = cx18_raw_readw(cx, src);
len -= 2; len -= 2;
to += 2; dst += 2;
from += 2; src += 2;
} }
while (len > 3) { while (len > 3) {
*((u32 *)to) = cx18_raw_readl(cx, from); *((u32 *)dst) = cx18_raw_readl(cx, src);
len -= 4; len -= 4;
to += 4; dst += 4;
from += 4; src += 4;
} }
if (len > 1) { if (len > 1) {
*((u16 *)to) = cx18_raw_readw(cx, from); *((u16 *)dst) = cx18_raw_readw(cx, src);
len -= 2; len -= 2;
to += 2; dst += 2;
from += 2; src += 2;
} }
if (len > 0) 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) void cx18_memset_io(struct cx18 *cx, void __iomem *addr, int val, size_t count)
{ {
u8 *dst = addr;
u16 val2 = val | (val << 8); u16 val2 = val | (val << 8);
u32 val4 = val2 | (val2 << 16); u32 val4 = val2 | (val2 << 16);
/* Align writes on the CX23418's addresses */ /* Align writes on the CX23418's addresses */
if ((count > 0) && ((unsigned)addr & 1)) { if ((count > 0) && ((unsigned long)dst & 1)) {
cx18_writeb(cx, (u8) val, addr); cx18_writeb(cx, (u8) val, dst);
count--; count--;
addr++; dst++;
} }
if ((count > 1) && ((unsigned)addr & 2)) { if ((count > 1) && ((unsigned long)dst & 2)) {
cx18_writew(cx, val2, addr); cx18_writew(cx, val2, dst);
count -= 2; count -= 2;
addr += 2; dst += 2;
} }
while (count > 3) { while (count > 3) {
cx18_writel(cx, val4, addr); cx18_writel(cx, val4, dst);
count -= 4; count -= 4;
addr += 4; dst += 4;
} }
if (count > 1) { if (count > 1) {
cx18_writew(cx, val2, addr); cx18_writew(cx, val2, dst);
count -= 2; count -= 2;
addr += 2; dst += 2;
} }
if (count > 0) 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) void cx18_sw1_irq_enable(struct cx18 *cx, u32 val)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment