powerpc/lib/code-patching: Use PPC_RAW_() macros
authorChristophe Leroy <christophe.leroy@csgroup.eu>
Thu, 20 May 2021 10:23:02 +0000 (10:23 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 15 Jun 2021 14:16:47 +0000 (00:16 +1000)
Instead of open coding with PPC_INST_ defines, use
PPC_RAW_() macros. It improves readability.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/8c92f1d9e825ee47c6f88fe43ad42d2a8cc2ab4a.1621506159.git.christophe.leroy@csgroup.eu
arch/powerpc/include/asm/code-patching.h
arch/powerpc/kernel/trace/ftrace.c

index f1d029b..22957c6 100644 (file)
@@ -73,9 +73,9 @@ void __patch_exception(int exc, unsigned long addr);
 #endif
 
 #define OP_RT_RA_MASK  0xffff0000UL
-#define LIS_R2         (PPC_INST_ADDIS | __PPC_RT(R2))
-#define ADDIS_R2_R12   (PPC_INST_ADDIS | __PPC_RT(R2) | __PPC_RA(R12))
-#define ADDI_R2_R2     (PPC_INST_ADDI  | __PPC_RT(R2) | __PPC_RA(R2))
+#define LIS_R2         (PPC_RAW_LIS(_R2, 0))
+#define ADDIS_R2_R12   (PPC_RAW_ADDIS(_R2, _R12, 0))
+#define ADDI_R2_R2     (PPC_RAW_ADDI(_R2, _R2, 0))
 
 
 static inline unsigned long ppc_function_entry(void *func)
@@ -180,12 +180,10 @@ static inline unsigned long ppc_kallsyms_lookup_name(const char *name)
 #define R2_STACK_OFFSET         40
 #endif
 
-#define PPC_INST_LD_TOC                (PPC_INST_LD  | ___PPC_RT(__REG_R2) | \
-                                ___PPC_RA(__REG_R1) | R2_STACK_OFFSET)
+#define PPC_INST_LD_TOC                PPC_RAW_LD(_R2, _R1, R2_STACK_OFFSET)
 
 /* usually preceded by a mflr r0 */
-#define PPC_INST_STD_LR                (PPC_INST_STD | ___PPC_RS(__REG_R0) | \
-                                ___PPC_RA(__REG_R1) | PPC_LR_STKOFF)
+#define PPC_INST_STD_LR                PPC_RAW_STD(_R0, _R1, PPC_LR_STKOFF)
 #endif /* CONFIG_PPC64 */
 
 #endif /* _ASM_POWERPC_CODE_PATCHING_H */
index ffe9537..9372203 100644 (file)
@@ -203,7 +203,7 @@ __ftrace_make_nop(struct module *mod,
        }
 
        if (!ppc_inst_equal(op,  ppc_inst(PPC_INST_LD_TOC))) {
-               pr_err("Expected %08x found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
+               pr_err("Expected %08lx found %s\n", PPC_INST_LD_TOC, ppc_inst_as_str(op));
                return -EINVAL;
        }
 #endif /* CONFIG_MPROFILE_KERNEL */