Commit f626190d authored by Anton Blanchard's avatar Anton Blanchard Committed by Benjamin Herrenschmidt

powerpc: Remove open coded byte swap macro in alignment handler

Use swab64/32/16 instead of open coding it.
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 5c0484e2
...@@ -54,8 +54,6 @@ struct aligninfo { ...@@ -54,8 +54,6 @@ struct aligninfo {
/* DSISR bits reported for a DCBZ instruction: */ /* DSISR bits reported for a DCBZ instruction: */
#define DCBZ 0x5f /* 8xx/82xx dcbz faults when cache not enabled */ #define DCBZ 0x5f /* 8xx/82xx dcbz faults when cache not enabled */
#define SWAP(a, b) (t = (a), (a) = (b), (b) = t)
/* /*
* The PowerPC stores certain bits of the instruction that caused the * The PowerPC stores certain bits of the instruction that caused the
* alignment exception in the DSISR register. This array maps those * alignment exception in the DSISR register. This array maps those
...@@ -458,7 +456,7 @@ static struct aligninfo spe_aligninfo[32] = { ...@@ -458,7 +456,7 @@ static struct aligninfo spe_aligninfo[32] = {
static int emulate_spe(struct pt_regs *regs, unsigned int reg, static int emulate_spe(struct pt_regs *regs, unsigned int reg,
unsigned int instr) unsigned int instr)
{ {
int t, ret; int ret;
union { union {
u64 ll; u64 ll;
u32 w[2]; u32 w[2];
...@@ -581,24 +579,18 @@ static int emulate_spe(struct pt_regs *regs, unsigned int reg, ...@@ -581,24 +579,18 @@ static int emulate_spe(struct pt_regs *regs, unsigned int reg,
if (flags & SW) { if (flags & SW) {
switch (flags & 0xf0) { switch (flags & 0xf0) {
case E8: case E8:
SWAP(data.v[0], data.v[7]); data.ll = swab64(data.ll);
SWAP(data.v[1], data.v[6]);
SWAP(data.v[2], data.v[5]);
SWAP(data.v[3], data.v[4]);
break; break;
case E4: case E4:
data.w[0] = swab32(data.w[0]);
SWAP(data.v[0], data.v[3]); data.w[1] = swab32(data.w[1]);
SWAP(data.v[1], data.v[2]);
SWAP(data.v[4], data.v[7]);
SWAP(data.v[5], data.v[6]);
break; break;
/* Its half word endian */ /* Its half word endian */
default: default:
SWAP(data.v[0], data.v[1]); data.h[0] = swab16(data.h[0]);
SWAP(data.v[2], data.v[3]); data.h[1] = swab16(data.h[1]);
SWAP(data.v[4], data.v[5]); data.h[2] = swab16(data.h[2]);
SWAP(data.v[6], data.v[7]); data.h[3] = swab16(data.h[3]);
break; break;
} }
} }
...@@ -710,7 +702,7 @@ int fix_alignment(struct pt_regs *regs) ...@@ -710,7 +702,7 @@ int fix_alignment(struct pt_regs *regs)
unsigned int dsisr; unsigned int dsisr;
unsigned char __user *addr; unsigned char __user *addr;
unsigned long p, swiz; unsigned long p, swiz;
int ret, t; int ret;
union { union {
u64 ll; u64 ll;
double dd; double dd;
...@@ -915,17 +907,13 @@ int fix_alignment(struct pt_regs *regs) ...@@ -915,17 +907,13 @@ int fix_alignment(struct pt_regs *regs)
if (flags & SW) { if (flags & SW) {
switch (nb) { switch (nb) {
case 8: case 8:
SWAP(data.v[0], data.v[7]); data.ll = swab64(data.ll);
SWAP(data.v[1], data.v[6]);
SWAP(data.v[2], data.v[5]);
SWAP(data.v[3], data.v[4]);
break; break;
case 4: case 4:
SWAP(data.v[4], data.v[7]); data.x32.low32 = swab32(data.x32.low32);
SWAP(data.v[5], data.v[6]);
break; break;
case 2: case 2:
SWAP(data.v[6], data.v[7]); data.x16.low16 = swab16(data.x16.low16);
break; break;
} }
} }
......
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