diff mbox series

[4/5] powerpc/fsl: Modernise mt/mfpmr

Message ID 20240229122521.762431-4-mpe@ellerman.id.au (mailing list archive)
State Accepted
Commit f01dbd73ccf122486ad4b52e74f5505985dd6af4
Headers show
Series [1/5] powerpc/64s: Move dcbt/dcbtst sequence into a macro | expand

Commit Message

Michael Ellerman Feb. 29, 2024, 12:25 p.m. UTC
With the addition of the machine directives, these are no longer simple
1-2 liner macros. So modernise them to be static inlines and use named
asm parameters.

Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/include/asm/reg_fsl_emb.h | 32 +++++++++++++++++---------
 1 file changed, 21 insertions(+), 11 deletions(-)

Comments

Segher Boessenkool Feb. 29, 2024, 5:23 p.m. UTC | #1
On Thu, Feb 29, 2024 at 11:25:20PM +1100, Michael Ellerman wrote:
> With the addition of the machine directives, these are no longer simple
> 1-2 liner macros. So modernise them to be static inlines and use named
> asm parameters.
> 
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

You got rid of the __stringify blight as well.  Great :-)

Acked-by: Segher Boessenkool <segher@kernel.crashing.org>


Segher
diff mbox series

Patch

diff --git a/arch/powerpc/include/asm/reg_fsl_emb.h b/arch/powerpc/include/asm/reg_fsl_emb.h
index 8359c06d92d9..b0563c30b062 100644
--- a/arch/powerpc/include/asm/reg_fsl_emb.h
+++ b/arch/powerpc/include/asm/reg_fsl_emb.h
@@ -11,17 +11,27 @@ 
 
 #ifndef __ASSEMBLY__
 /* Performance Monitor Registers */
-#define mfpmr(rn)	({unsigned int rval; \
-			asm volatile(".machine push; " \
-				     ".machine e300; " \
-				     "mfpmr %0," __stringify(rn) ";" \
-				     ".machine pop; " \
-				     : "=r" (rval)); rval;})
-#define mtpmr(rn, v)	asm volatile(".machine push; " \
-				     ".machine e300; " \
-				     "mtpmr " __stringify(rn) ",%0; " \
-				     ".machine pop; " \
-				     : : "r" (v))
+static inline unsigned int mfpmr(unsigned int rn)
+{
+	unsigned int rval;
+
+	asm (".machine push; "
+	     ".machine e300; "
+	     "mfpmr %[rval], %[rn];"
+	     ".machine pop;"
+	     : [rval] "=r" (rval) : [rn] "i" (rn));
+
+	return rval;
+}
+
+static inline void mtpmr(unsigned int rn, unsigned int val)
+{
+	asm (".machine push; "
+	     ".machine e300; "
+	     "mtpmr %[rn], %[val];"
+	     ".machine pop;"
+	     : [val] "=r" (val) : [rn] "i" (rn));
+}
 #endif /* __ASSEMBLY__ */
 
 /* Freescale Book E Performance Monitor APU Registers */