Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/inst: Refactor ___get_user_instr()

PPC64 version of ___get_user_instr() can be used for PPC32 as well,
by simply disabling the suffix part with IS_ENABLED(CONFIG_PPC64).

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/1f0ede830ccb33a659119a55cb590820c27004db.1638208156.git.christophe.leroy@csgroup.eu

authored by

Christophe Leroy and committed by
Michael Ellerman
3261d99a 37eb7ca9

+2 -11
+2 -11
arch/powerpc/include/asm/inst.h
··· 4 4 5 5 #include <asm/ppc-opcode.h> 6 6 7 - #ifdef CONFIG_PPC64 8 - 9 7 #define ___get_user_instr(gu_op, dest, ptr) \ 10 8 ({ \ 11 9 long __gui_ret; \ ··· 14 16 __chk_user_ptr(ptr); \ 15 17 __gui_ret = gu_op(__prefix, __gui_ptr); \ 16 18 if (__gui_ret == 0) { \ 17 - if ((__prefix >> 26) == OP_PREFIX) { \ 19 + if (IS_ENABLED(CONFIG_PPC64) && (__prefix >> 26) == OP_PREFIX) { \ 18 20 __gui_ret = gu_op(__suffix, __gui_ptr + 1); \ 19 21 __gui_inst = ppc_inst_prefix(__prefix, __suffix); \ 20 22 } else { \ ··· 25 27 } \ 26 28 __gui_ret; \ 27 29 }) 28 - #else /* !CONFIG_PPC64 */ 29 - #define ___get_user_instr(gu_op, dest, ptr) \ 30 - ({ \ 31 - __chk_user_ptr(ptr); \ 32 - gu_op((dest).val, (u32 __user *)(ptr)); \ 33 - }) 34 - #endif /* CONFIG_PPC64 */ 35 30 36 31 #define get_user_instr(x, ptr) ___get_user_instr(get_user, x, ptr) 37 32 ··· 62 71 } 63 72 64 73 #else 65 - #define ppc_inst_prefix(x, y) ppc_inst(x) 74 + #define ppc_inst_prefix(x, y) ((void)y, ppc_inst(x)) 66 75 67 76 static inline u32 ppc_inst_suffix(struct ppc_inst x) 68 77 {