diff options
author | Maciej W. Rozycki <macro@imgtec.com> | 2016-01-22 00:21:47 -0500 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2016-01-23 19:37:09 -0500 |
commit | 6d7b14151d7510ed434f2e587cdae9eca82fc123 (patch) | |
tree | e5f9b52b4fa8e1da01346d7b39eeb5f70fab2f78 /arch/mips/math-emu/dsemul.c | |
parent | 29e280034810efeb84ca67a535817cf45e7cd7fe (diff) |
MIPS: math-emu: dsemul: Reduce `get_isa16_mode' clutter
Signed-off-by: Maciej W. Rozycki <macro@imgtec.com>
Cc: Aurelien Jarno <aurelien@aurel32.net>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/12178/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/math-emu/dsemul.c')
-rw-r--r-- | arch/mips/math-emu/dsemul.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/arch/mips/math-emu/dsemul.c b/arch/mips/math-emu/dsemul.c index bca7c4367ca4..46b964d2b79c 100644 --- a/arch/mips/math-emu/dsemul.c +++ b/arch/mips/math-emu/dsemul.c | |||
@@ -38,6 +38,7 @@ struct emuframe { | |||
38 | */ | 38 | */ |
39 | int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc) | 39 | int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc) |
40 | { | 40 | { |
41 | int isa16 = get_isa16_mode(regs->cp0_epc); | ||
41 | mips_instruction break_math; | 42 | mips_instruction break_math; |
42 | struct emuframe __user *fr; | 43 | struct emuframe __user *fr; |
43 | int err; | 44 | int err; |
@@ -47,7 +48,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc) | |||
47 | return -1; | 48 | return -1; |
48 | 49 | ||
49 | /* microMIPS instructions */ | 50 | /* microMIPS instructions */ |
50 | if (get_isa16_mode(regs->cp0_epc)) { | 51 | if (isa16) { |
51 | union mips_instruction insn = { .word = ir }; | 52 | union mips_instruction insn = { .word = ir }; |
52 | 53 | ||
53 | /* NOP16 aka MOVE16 $0, $0 */ | 54 | /* NOP16 aka MOVE16 $0, $0 */ |
@@ -81,7 +82,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc) | |||
81 | * multiprocessor support. For Linux we use a BREAK 514 | 82 | * multiprocessor support. For Linux we use a BREAK 514 |
82 | * instruction causing a breakpoint exception. | 83 | * instruction causing a breakpoint exception. |
83 | */ | 84 | */ |
84 | break_math = BREAK_MATH(get_isa16_mode(regs->cp0_epc)); | 85 | break_math = BREAK_MATH(isa16); |
85 | 86 | ||
86 | /* Ensure that the two instructions are in the same cache line */ | 87 | /* Ensure that the two instructions are in the same cache line */ |
87 | fr = (struct emuframe __user *) | 88 | fr = (struct emuframe __user *) |
@@ -91,7 +92,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc) | |||
91 | if (unlikely(!access_ok(VERIFY_WRITE, fr, sizeof(struct emuframe)))) | 92 | if (unlikely(!access_ok(VERIFY_WRITE, fr, sizeof(struct emuframe)))) |
92 | return SIGBUS; | 93 | return SIGBUS; |
93 | 94 | ||
94 | if (get_isa16_mode(regs->cp0_epc)) { | 95 | if (isa16) { |
95 | err = __put_user(ir >> 16, | 96 | err = __put_user(ir >> 16, |
96 | (u16 __user *)(&fr->emul)); | 97 | (u16 __user *)(&fr->emul)); |
97 | err |= __put_user(ir & 0xffff, | 98 | err |= __put_user(ir & 0xffff, |
@@ -113,8 +114,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc) | |||
113 | return SIGBUS; | 114 | return SIGBUS; |
114 | } | 115 | } |
115 | 116 | ||
116 | regs->cp0_epc = ((unsigned long) &fr->emul) | | 117 | regs->cp0_epc = (unsigned long)&fr->emul | isa16; |
117 | get_isa16_mode(regs->cp0_epc); | ||
118 | 118 | ||
119 | flush_cache_sigtramp((unsigned long)&fr->emul); | 119 | flush_cache_sigtramp((unsigned long)&fr->emul); |
120 | 120 | ||
@@ -123,6 +123,7 @@ int mips_dsemul(struct pt_regs *regs, mips_instruction ir, unsigned long cpc) | |||
123 | 123 | ||
124 | int do_dsemulret(struct pt_regs *xcp) | 124 | int do_dsemulret(struct pt_regs *xcp) |
125 | { | 125 | { |
126 | int isa16 = get_isa16_mode(xcp->cp0_epc); | ||
126 | struct emuframe __user *fr; | 127 | struct emuframe __user *fr; |
127 | unsigned long epc; | 128 | unsigned long epc; |
128 | u32 insn, cookie; | 129 | u32 insn, cookie; |
@@ -145,7 +146,7 @@ int do_dsemulret(struct pt_regs *xcp) | |||
145 | * - Is the instruction pointed to by the EPC an BREAK_MATH? | 146 | * - Is the instruction pointed to by the EPC an BREAK_MATH? |
146 | * - Is the following memory word the BD_COOKIE? | 147 | * - Is the following memory word the BD_COOKIE? |
147 | */ | 148 | */ |
148 | if (get_isa16_mode(xcp->cp0_epc)) { | 149 | if (isa16) { |
149 | err = __get_user(instr[0], | 150 | err = __get_user(instr[0], |
150 | (u16 __user *)(&fr->badinst)); | 151 | (u16 __user *)(&fr->badinst)); |
151 | err |= __get_user(instr[1], | 152 | err |= __get_user(instr[1], |
@@ -156,8 +157,8 @@ int do_dsemulret(struct pt_regs *xcp) | |||
156 | } | 157 | } |
157 | err |= __get_user(cookie, &fr->cookie); | 158 | err |= __get_user(cookie, &fr->cookie); |
158 | 159 | ||
159 | if (unlikely(err || insn != BREAK_MATH(get_isa16_mode(xcp->cp0_epc)) || | 160 | if (unlikely(err || |
160 | cookie != BD_COOKIE)) { | 161 | insn != BREAK_MATH(isa16) || cookie != BD_COOKIE)) { |
161 | MIPS_FPU_EMU_INC_STATS(errors); | 162 | MIPS_FPU_EMU_INC_STATS(errors); |
162 | return 0; | 163 | return 0; |
163 | } | 164 | } |