From patchwork Tue Jan 26 09:23:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vladimir Murzin X-Patchwork-Id: 8119171 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7A4F59F8AA for ; Tue, 26 Jan 2016 09:26:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BA1AB2026D for ; Tue, 26 Jan 2016 09:26:18 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BE4532024F for ; Tue, 26 Jan 2016 09:26:17 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aNzra-0001lW-H5; Tue, 26 Jan 2016 09:24:38 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1aNzrG-0001XR-Ip for linux-arm-kernel@lists.infradead.org; Tue, 26 Jan 2016 09:24:20 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id BEA4258F; Tue, 26 Jan 2016 01:23:17 -0800 (PST) Received: from login1.euhpc.arm.com (login1.euhpc.arm.com [10.6.26.143]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 107CB3F21A; Tue, 26 Jan 2016 01:23:57 -0800 (PST) From: Vladimir Murzin To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 3/4] ARM: introduce cpu feature helper for unsigned values Date: Tue, 26 Jan 2016 09:23:42 +0000 Message-Id: <1453800223-18590-4-git-send-email-vladimir.murzin@arm.com> X-Mailer: git-send-email 2.0.0 In-Reply-To: <1453800223-18590-1-git-send-email-vladimir.murzin@arm.com> References: <1453800223-18590-1-git-send-email-vladimir.murzin@arm.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160126_012418_670373_8E178B03 X-CRM114-Status: UNSURE ( 7.40 ) X-CRM114-Notice: Please train this message. X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux@arm.linux.org.uk, ard.biesheuvel@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Some of the CPU feature bits have unsigned values and need to be treated accordingly to avoid errors. Add the new cpu feature helper for such cases. Signed-off-by: Vladimir Murzin --- arch/arm/include/asm/cputype.h | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h index 1ee94c7..d93ced5 100644 --- a/arch/arm/include/asm/cputype.h +++ b/arch/arm/include/asm/cputype.h @@ -270,8 +270,15 @@ static inline int cpu_is_pj4(void) #define cpu_is_pj4() 0 #endif -static inline int __attribute_const__ cpuid_feature_extract_field(u32 features, - int field) + +static inline unsigned int __attribute_const__ +cpuid_feature_extract_unsigned_field(u32 features, int field) +{ + return (features >> field) & 15; +} + +static inline int __attribute_const__ +cpuid_feature_extract_field(u32 features, int field) { int feature = (features >> field) & 15; @@ -285,4 +292,7 @@ static inline int __attribute_const__ cpuid_feature_extract_field(u32 features, #define cpuid_feature_extract(reg, field) \ cpuid_feature_extract_field(read_cpuid_ext(reg), field) +#define cpuid_feature_extract_unsigned(reg, field) \ + cpuid_feature_extract_unsigned_field(read_cpuid_ext(reg), field) + #endif