linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ARM: ptrace: Use bitfield helpers
@ 2021-11-22 15:53 Geert Uytterhoeven
  2021-11-22 15:53 ` [PATCH] MIPS: CPC: " Geert Uytterhoeven
                   ` (10 more replies)
  0 siblings, 11 replies; 19+ messages in thread
From: Geert Uytterhoeven @ 2021-11-22 15:53 UTC (permalink / raw)
  To: Oleg Nesterov, Russell King, Uwe Kleine-König
  Cc: linux-arm-kernel, linux-kernel, Geert Uytterhoeven

The isa_mode() macro extracts two fields, and recombines them into a
single value.  The shift value of the J-bit may look off-by-one to the
casual reader, as it is the net result of the extraction and
recombination steps.

Make this more obvious by using the FIELD_GET() helper, and shifting the
result into its final resting place.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
No changes in generated assembler code.

See "[PATCH 00/17] Non-const bitfield helper conversions"
(https://lore.kernel.org/r/cover.1637592133.git.geert+renesas@glider.be)
for background and more conversions.
---
 arch/arm/include/asm/ptrace.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/arch/arm/include/asm/ptrace.h b/arch/arm/include/asm/ptrace.h
index 93051e2f402c8452..982514aa83c1f459 100644
--- a/arch/arm/include/asm/ptrace.h
+++ b/arch/arm/include/asm/ptrace.h
@@ -10,6 +10,7 @@
 #include <uapi/asm/ptrace.h>
 
 #ifndef __ASSEMBLY__
+#include <linux/bitfield.h>
 #include <linux/types.h>
 
 struct pt_regs {
@@ -35,8 +36,8 @@ struct svc_pt_regs {
 
 #ifndef CONFIG_CPU_V7M
 #define isa_mode(regs) \
-	((((regs)->ARM_cpsr & PSR_J_BIT) >> (__ffs(PSR_J_BIT) - 1)) | \
-	 (((regs)->ARM_cpsr & PSR_T_BIT) >> (__ffs(PSR_T_BIT))))
+	((FIELD_GET(PSR_J_BIT, (regs)->ARM_cpsr) << 1) | \
+	 FIELD_GET(PSR_T_BIT, (regs)->ARM_cpsr))
 #else
 #define isa_mode(regs) 1 /* Thumb */
 #endif
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2021-12-13  9:05 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-22 15:53 [PATCH] ARM: ptrace: Use bitfield helpers Geert Uytterhoeven
2021-11-22 15:53 ` [PATCH] MIPS: CPC: " Geert Uytterhoeven
2021-11-29 12:32   ` Thomas Bogendoerfer
2021-11-22 15:53 ` [PATCH] MIPS: CPS: " Geert Uytterhoeven
2021-11-29 12:32   ` Thomas Bogendoerfer
2021-11-22 15:54 ` [PATCH] crypto: sa2ul - " Geert Uytterhoeven
2021-12-03  5:07   ` Herbert Xu
2021-11-22 15:54 ` [PATCH] dmaengine: stm32-mdma: " Geert Uytterhoeven
2021-11-26 11:02   ` [Linux-stm32] " Amelie DELAUNAY
2021-12-13  9:05   ` Vinod Koul
2021-11-22 15:54 ` [PATCH] intel_th: " Geert Uytterhoeven
2021-11-22 15:54 ` [PATCH] Input: palmas-pwrbutton - use " Geert Uytterhoeven
2021-11-22 15:54 ` [PATCH] irqchip/mips-gic: Use " Geert Uytterhoeven
2021-11-22 15:54 ` [PATCH] mfd: mc13xxx: " Geert Uytterhoeven
2021-11-22 15:54 ` [PATCH] regulator: lp873x: " Geert Uytterhoeven
2021-11-22 16:32   ` Mark Brown
2021-11-22 15:54 ` [PATCH] regulator: lp87565: " Geert Uytterhoeven
2021-11-22 16:33   ` Mark Brown
2021-11-22 16:17 ` [PATCH] ARM: ptrace: " Russell King (Oracle)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).