Commit 1758ef68 authored by Harvey Harrison's avatar Harvey Harrison Committed by David S. Miller

sparc64: remove byteshifting from out* helpers

__raw_write avoids the need to byteswap, as we are reading from a
host-endian area, just deref the pointers directly, taking care
of alignment.

As before, outsw must be called with a 2-byte aligned pointer.
Signed-off-by: default avatarHarvey Harrison <harvey.harrison@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 60b82673
...@@ -20,108 +20,63 @@ void outsw(unsigned long __addr, const void *src, unsigned long count) ...@@ -20,108 +20,63 @@ void outsw(unsigned long __addr, const void *src, unsigned long count)
{ {
void __iomem *addr = (void __iomem *) __addr; void __iomem *addr = (void __iomem *) __addr;
if (count) { while (count--) {
u16 *ps = (u16 *)src; __raw_writew(*(u16 *)src, addr);
u32 *pi; src += sizeof(u16);
if (((u64)src) & 0x2) {
u16 val = le16_to_cpup(ps);
outw(val, addr);
ps++;
count--;
}
pi = (u32 *)ps;
while (count >= 2) {
u32 w = le32_to_cpup(pi);
pi++;
outw(w >> 0, addr);
outw(w >> 16, addr);
count -= 2;
}
ps = (u16 *)pi;
if (count) {
u16 val = le16_to_cpup(ps);
outw(val, addr);
}
} }
} }
void outsl(unsigned long __addr, const void *src, unsigned long count) void outsl(unsigned long __addr, const void *src, unsigned long count)
{ {
void __iomem *addr = (void __iomem *) __addr; void __iomem *addr = (void __iomem *) __addr;
u32 l, l2;
if (count) { if (!count)
if ((((u64)src) & 0x3) == 0) { return;
u32 *p = (u32 *)src;
switch (((unsigned long)src) & 0x3) {
case 0x0:
/* src is naturally aligned */
while (count--) { while (count--) {
u32 val = cpu_to_le32p(p); __raw_writel(*(u32 *)src, addr);
outl(val, addr); src += sizeof(u32);
p++;
} }
} else { break;
u8 *pb;
u16 *ps = (u16 *)src;
u32 l = 0, l2;
u32 *pi;
switch (((u64)src) & 0x3) {
case 0x2: case 0x2:
count -= 1; /* 2-byte alignment */
l = cpu_to_le16p(ps) << 16;
ps++;
pi = (u32 *)ps;
while (count--) { while (count--) {
l2 = cpu_to_le32p(pi); l = (*(u16 *)src) << 16;
pi++; l |= *(u16 *)(src + sizeof(u16));
outl(((l >> 16) | (l2 << 16)), addr); __raw_writel(l, addr);
l = l2; src += sizeof(u32);
} }
ps = (u16 *)pi;
l2 = cpu_to_le16p(ps);
outl(((l >> 16) | (l2 << 16)), addr);
break; break;
case 0x1: case 0x1:
count -= 1; /* Hold three bytes in l each time, grab a byte from l2 */
pb = (u8 *)src; l = (*(u8 *)src) << 24;
l = (*pb++ << 8); l |= (*(u16 *)(src + sizeof(u8))) << 8;
ps = (u16 *)pb; src += sizeof(u8) + sizeof(u16);
l2 = cpu_to_le16p(ps);
ps++;
l |= (l2 << 16);
pi = (u32 *)ps;
while (count--) { while (count--) {
l2 = cpu_to_le32p(pi); l2 = *(u32 *)src;
pi++; l |= (l2 >> 24);
outl(((l >> 8) | (l2 << 24)), addr); __raw_writel(l, addr);
l = l2; l = l2 << 8;
src += sizeof(u32);
} }
pb = (u8 *)pi;
outl(((l >> 8) | (*pb << 24)), addr);
break; break;
case 0x3: case 0x3:
count -= 1; /* Hold a byte in l each time, grab 3 bytes from l2 */
pb = (u8 *)src; l = (*(u8 *)src) << 24;
l = (*pb++ << 24); src += sizeof(u8);
pi = (u32 *)pb;
while (count--) { while (count--) {
l2 = cpu_to_le32p(pi); l2 = *(u32 *)src;
pi++; l |= (l2 >> 8);
outl(((l >> 24) | (l2 << 8)), addr); __raw_writel(l, addr);
l = l2; l = l2 << 24;
src += sizeof(u32);
} }
ps = (u16 *)pi;
l2 = cpu_to_le16p(ps);
ps++;
pb = (u8 *)ps;
l2 |= (*pb << 16);
outl(((l >> 24) | (l2 << 8)), addr);
break; break;
} }
}
}
} }
void insb(unsigned long __addr, void *dst, unsigned long count) void insb(unsigned long __addr, void *dst, unsigned long count)
......
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