Re: [PATCH v2] ARM: ptrace: Use bitfield helpers

From: Oleg Nesterov
Date: Thu Feb 15 2024 - 12:51:44 EST


Sorry for the noise, can't resist...

I am replying only because I wasn't aware of bitfield.h and useful
helpers there.

Thank you ;)

On 02/15, Geert Uytterhoeven wrote:
>
> #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))

Reviewed-by: Oleg Nesterov <oleg@xxxxxxxxxx>