Skip to contentSkip to conversation

powerpc/math-emu: two minor cleanup patches for math.c

PATCH Superseded Kevin Hao 3 participants 8 messages Jul 10, 2013 PowerPC

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Kevin Hao

author
#0 lore raw

cover powerpc/math-emu: two minor cleanup patches for math.c

Just remove some dead or unneeded codes in math.c. No function change.

Kevin Hao (2):
powerpc/math-emu: remove the dead code in math.c powerpc/math-emu: remove the unneeded check for CONFIG_MATH_EMULATION
in math.c

 arch/powerpc/math-emu/math.c | 46 --------------------------------------------
 1 file changed, 46 deletions(-)
Signature · 1 line
1.8.1.4
author
#1 lore raw

PATCH 1/2 powerpc/math-emu: remove the dead code in math.c

The math.c is only built when CONFIG_MATH_EMULATION is enabled. So we would never get into the case that CONFIG_MATH_EMULATION is not defined in this file.

---
 arch/powerpc/math-emu/math.c | 42 ------------------------------------------
 1 file changed, 42 deletions(-)
arch/powerpc/math-emu/math.c +0 -42
index 0328e66..cefb4f2 100644
@@ -231,47 +231,6 @@ do_mathemu(struct pt_regs *regs)
 	if (get_user(insn, (u32 *)pc))
 		return -EFAULT;
 
-#ifndef CONFIG_MATH_EMULATION
-	switch (insn >> 26) {
-	case LFD:
-		idx = (insn >> 16) & 0x1f;
-		sdisp = (insn & 0xffff);
-		op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
-		op1 = (void *)((idx ? regs->gpr[idx] : 0) + sdisp);
-		lfd(op0, op1, op2, op3);
-		break;
-	case LFDU:
-		idx = (insn >> 16) & 0x1f;
-		sdisp = (insn & 0xffff);
-		op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
-		op1 = (void *)((idx ? regs->gpr[idx] : 0) + sdisp);
-		lfd(op0, op1, op2, op3);
-		regs->gpr[idx] = (unsigned long)op1;
-		break;
-	case STFD:
-		idx = (insn >> 16) & 0x1f;
-		sdisp = (insn & 0xffff);
-		op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
-		op1 = (void *)((idx ? regs->gpr[idx] : 0) + sdisp);
-		stfd(op0, op1, op2, op3);
-		break;
-	case STFDU:
-		idx = (insn >> 16) & 0x1f;
-		sdisp = (insn & 0xffff);
-		op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
-		op1 = (void *)((idx ? regs->gpr[idx] : 0) + sdisp);
-		stfd(op0, op1, op2, op3);
-		regs->gpr[idx] = (unsigned long)op1;
-		break;
-	case OP63:
-		op0 = (void *)&current->thread.TS_FPR((insn >> 21) & 0x1f);
-		op1 = (void *)&current->thread.TS_FPR((insn >> 11) & 0x1f);
-		fmr(op0, op1, op2, op3);
-		break;
-	default:
-		goto illegal;
-	}
-#else /* CONFIG_MATH_EMULATION */
 	switch (insn >> 26) {
 	case LFS:	func = lfs;	type = D;	break;
 	case LFSU:	func = lfs;	type = DU;	break;
@@ -485,7 +444,6 @@ do_mathemu(struct pt_regs *regs)
 	default:
 		break;
 	}
-#endif /* CONFIG_MATH_EMULATION */
 
 	regs->nip += 4;
 	return 0;
Signature · 1 line
1.8.1.4
author
#7 lore raw

PATCH 2/2 powerpc/math-emu: remove the unneeded check for CONFIG_MATH_EMULATION in math.c

In reply to Kevin Hao

The math.c is only built when CONFIG_MATH_EMULATION is enabled. So the #ifdef check for CONFIG_MATH_EMULATION in it seems redundant. Drop all of them.

---
 arch/powerpc/math-emu/math.c | 4 ----
 1 file changed, 4 deletions(-)
arch/powerpc/math-emu/math.c +0 -4
index cefb4f2..3fe8e35 100644
@@ -154,7 +154,6 @@ FLOATFUNC(fsqrts);
 #define XEU	15
 #define XFLB	10
 
-#ifdef CONFIG_MATH_EMULATION
 static int
 record_exception(struct pt_regs *regs, int eflag)
 {
@@ -212,7 +211,6 @@ record_exception(struct pt_regs *regs, int eflag)
 
 	return (fpscr & FPSCR_FEX) ? 1 : 0;
 }
-#endif /* CONFIG_MATH_EMULATION */
 
 int
 do_mathemu(struct pt_regs *regs)
@@ -222,11 +220,9 @@ do_mathemu(struct pt_regs *regs)
 	signed short sdisp;
 	u32 insn = 0;
 	int idx = 0;
-#ifdef CONFIG_MATH_EMULATION
 	int (*func)(void *, void *, void *, void *);
 	int type = 0;
 	int eflag, trap;
-#endif
 
 	if (get_user(insn, (u32 *)pc))
 		return -EFAULT;
Signature · 1 line
1.8.1.4
#2 lore raw

Re: [PATCH 1/2] powerpc/math-emu: remove the dead code in math.c

In reply to Kevin Hao
Quoted 3 lines · Kevin Hao

The math.c is only built when CONFIG_MATH_EMULATION is enabled. So we would never get into the case that CONFIG_MATH_EMULATION is not defined in this file.

Any idea why we have that there? ie. have the config symbols changed over time or was this always dead code?

cheers

author
#3 lore raw

Re: [PATCH 1/2] powerpc/math-emu: remove the dead code in math.c

Quoted 7 lines · Michael Ellerman
Quoted 3 lines · Kevin Hao

The math.c is only built when CONFIG_MATH_EMULATION is enabled. So we would never get into the case that CONFIG_MATH_EMULATION is not defined in this file.

Any idea why we have that there? ie. have the config symbols changed over time or was this always dead code?

No idea. I tried to trace this before submitting the patch. But it has been there since the begin of the git history. So I just assume that it is always dead code. :-)

Thanks,
Kevin

Quoted 2 lines

cheers

#4 lore raw

Re: [PATCH 1/2] powerpc/math-emu: remove the dead code in math.c

Quoted 6 lines · Kevin Hao
Quoted 5 lines · Michael Ellerman
Quoted 3 lines · Kevin Hao

The math.c is only built when CONFIG_MATH_EMULATION is enabled. So we would never get into the case that CONFIG_MATH_EMULATION is not defined in this file.

Quoted 6 lines
Quoted 2 lines

Any idea why we have that there? ie. have the config symbols changed over time or was this always dead code?

No idea. I tried to trace this before submitting the patch. But it has been there since the begin of the git history. So I just assume that it is always dead code. :-)

Yeah looks like it. Even in the git-huge tree I see it in the initial commit.

You should say that in the commit message though. Otherwise it's not clear if you're fixing a recent breakage or not.

cheers

author
#5 lore raw

Re: [PATCH 1/2] powerpc/math-emu: remove the dead code in math.c

Quoted 10 lines · Michael Ellerman
Quoted 9 lines · Kevin Hao
Quoted 7 lines · Michael Ellerman
Quoted 3 lines · Kevin Hao

The math.c is only built when CONFIG_MATH_EMULATION is enabled. So we would never get into the case that CONFIG_MATH_EMULATION is not defined in this file.

Any idea why we have that there? ie. have the config symbols changed over time or was this always dead code?

Quoted 6 lines
Quoted 3 lines

No idea. I tried to trace this before submitting the patch. But it has been there since the begin of the git history. So I just assume that it is always dead code. :-)

Yeah looks like it. Even in the git-huge tree I see it in the initial commit.

Thanks for the confirmation.

Quoted 3 lines

You should say that in the commit message though. Otherwise it's not clear if you're fixing a recent breakage or not.

Indeed. I will wait a little to see if there are any other comments. Then respin a new version to capture such info in the commit log.

Thanks,
Kevin

Quoted 2 lines

cheers

#6 lore raw

Re: [PATCH 1/2] powerpc/math-emu: remove the dead code in math.c

In reply to Michael Ellerman
Quoted 7 lines · Michael Ellerman
Quoted 6 lines
Quoted 2 lines

Any idea why we have that there? ie. have the config symbols changed over time or was this always dead code?

No idea. I tried to trace this before submitting the patch. But it has been there since the begin of the git history. So I just assume that it is always dead code. :-)

Quoted 5 lines

Yeah looks like it. Even in the git-huge tree I see it in the initial commit.

You should say that in the commit message though. Otherwise it's not clear if you're fixing a recent breakage or not.

This is ancient code that was meant to emulate only load/stores/fmr without the rest of the emulation. The goal was to be able to boot userspace that was compiled without -msoft-float to *some* extent (bcs it would potentially use fp load/stores for things like memcpy) on small CPUs where the kernel footprint was critical.

It's been obsolete for a while now.

Cheers,
Ben.