From patchwork Thu Feb 15 13:54:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 13558435 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 03655C4829E for ; Thu, 15 Feb 2024 13:55:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=TgCnOVwj4rh9pOf2vVmxZC7/5j8w5INSO4S8RTSfhVg=; b=oLvlgBBO2vPf4U HeiTjsesCv356ogiaEP5cFkKR6rr14IgYbday15dcngSV9VJ+ZagzezbrOoj1z3bVbVzqwUql2NPU 3NcWDopNkPKVPuwi0+9yWu1MzWkRE1OY1WyLgfptwLCOHX9Qi7OENun/hogJc+ZI3uWC2N21Z+Nwc 7JRADe11tst07dSLwwwDwDuKerJCdYWg65UwxuKxHegM/vY8B1NKGRxtfKQLwgIJKRQkLgtqaohVP lXF++ZTu5VqRGiVblE4n/iMs56l9TeWW0u9TIA7kozC1s9h94hb+PlWnYddZOOj4J6kIanhZrlaUE MBpLfrdG5rk6WiQbcCXw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1racCd-0000000GT3A-0Pp7; Thu, 15 Feb 2024 13:55:03 +0000 Received: from andre.telenet-ops.be ([2a02:1800:120:4::f00:15]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1racCZ-0000000GT0G-3os4 for linux-arm-kernel@lists.infradead.org; Thu, 15 Feb 2024 13:55:01 +0000 Received: from ramsan.of.borg ([IPv6:2a02:1810:ac12:ed40:ac52:3a54:2a84:d65a]) by andre.telenet-ops.be with bizsmtp id nRus2B00J0LVNSS01Rusre; Thu, 15 Feb 2024 14:54:53 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan.of.borg with esmtp (Exim 4.95) (envelope-from ) id 1racCL-000hBv-8e; Thu, 15 Feb 2024 14:54:52 +0100 Received: from geert by rox.of.borg with local (Exim 4.95) (envelope-from ) id 1racCS-00Hacm-JG; Thu, 15 Feb 2024 14:54:52 +0100 From: Geert Uytterhoeven To: Oleg Nesterov , Russell King , =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2] ARM: ptrace: Use bitfield helpers Date: Thu, 15 Feb 2024 14:54:48 +0100 Message-Id: X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240215_055500_106396_EE630FF1 X-CRM114-Status: GOOD ( 10.86 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The isa_mode() macro extracts two fields, and recombines them into a single value. Make this more obvious by using the FIELD_GET() helper, and shifting the result into its final resting place. Signed-off-by: Geert Uytterhoeven Reviewed-by: Oleg Nesterov --- No changes in generated assembler code. v2: - Drop irrelevant comment about non-existing off-by-one error, - Remove unnecessary parens. --- 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 7f44e88d1f25bcc5..14a38cc67e0bc966 100644 --- a/arch/arm/include/asm/ptrace.h +++ b/arch/arm/include/asm/ptrace.h @@ -10,6 +10,7 @@ #include #ifndef __ASSEMBLY__ +#include #include 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