From patchwork Fri Jun 1 16:06:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 137548 Delivered-To: patch@linaro.org Received: by 2002:a2e:9706:0:0:0:0:0 with SMTP id r6-v6csp1128018lji; Fri, 1 Jun 2018 09:07:30 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKWoaXHH+OxjFxQGTUWkIkSBLzT0TTDfFhkxz2o+8Brqwf+4CykQqIFciLSgR7ts414julg X-Received: by 2002:a17:902:7484:: with SMTP id h4-v6mr11455023pll.154.1527869250081; Fri, 01 Jun 2018 09:07:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527869250; cv=none; d=google.com; s=arc-20160816; b=yzZf7Ue1YpuJOKB2TbHGfosuf0aATC/07sJT5WtYdHtT3VGqjcUUDdt+8X1SqMAOla XKi7ZzyvJtT+W7F02NVhYNxdNOZDZJtTx2TyX5B1Q+Zzf60G/xN+k03/pA5IO8+GnUHM Wopi1qfvBWzZTec/fkqhjLf3OxzO3D6JWvqDqKgrWwsTnbH2r6PmOYdGszheE5YVWj3O MtL93jQHvyj37YycNeTTLDayXlWSmr/mA/EkU0S4WUTztQ4912rD5t7tamR9BiSCvBHi nlscEap195nATicFSNbYsXE+wHSEIprI2CsvProYZVc07+BalA0TiPzCy+XxtcBGjEzM bdNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=dxsWqaY+cyvP9/Wn+QoATPyiIJKTrgv/4wVaFT6fg7E=; b=wLrwD2DZGs4znqpYrDS94+LVaSwpFklj0y/0MPmkRdHf4t1wuFa5vnZbKRkcO3F0cj htrW7nJEs/4sPEuB7EMhK7vMxI2I48L9v4UiQL9AgsTUGd0HD+Z/80exCLMPKN7OftTc 5KSnQm0gyJgYoGynm+3sAG5oAATBEK2LIjCeQVDWdm+m9lIBJr4ZkgTUAXG/50B4uM2W wbg28qrMv34Y4l0kcSf02/v+JEvVM2L+SwxOI3LBHDmErD3OUNhkdFMk1kLIw7/KQ9Ph q3IpRQtftkR7AJDAJ8Kc+s0v9WIvu3KxcY8Ae0BurbDSrYNAnIKdmT87zC4pF82tRmhy Ky1A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b7-v6si9712327pgq.564.2018.06.01.09.07.29; Fri, 01 Jun 2018 09:07:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752370AbeFAQH2 (ORCPT + 30 others); Fri, 1 Jun 2018 12:07:28 -0400 Received: from foss.arm.com ([217.140.101.70]:54972 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751693AbeFAQGA (ORCPT ); Fri, 1 Jun 2018 12:06:00 -0400 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 E8AE4164F; Fri, 1 Jun 2018 09:05:59 -0700 (PDT) Received: from edgewater-inn.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BAD983F557; Fri, 1 Jun 2018 09:05:59 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id 41DF31AE5058; Fri, 1 Jun 2018 17:06:30 +0100 (BST) From: Will Deacon To: linux-kernel@vger.kernel.org Cc: peterz@infradead.org, mingo@kernel.org, linux-arm-kernel@lists.infradead.org, yamada.masahiro@socionext.com, Will Deacon Subject: [PATCH v2 3/9] asm-generic: Move some macros from linux/bitops.h to a new bits.h file Date: Fri, 1 Jun 2018 17:06:23 +0100 Message-Id: <1527869189-31512-4-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1527869189-31512-1-git-send-email-will.deacon@arm.com> References: <1527869189-31512-1-git-send-email-will.deacon@arm.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In preparation for implementing the asm-generic atomic bitops in terms of atomic_long_*, we need to prevent asm/atomic.h implementations from pulling in linux/bitops.h. A common reason for this include is for the BITS_PER_BYTE definition, so move this and some other BIT and masking macros into a new header file, linux/bits.h Signed-off-by: Will Deacon --- include/linux/bitops.h | 22 +--------------------- include/linux/bits.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 include/linux/bits.h -- 2.1.4 diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 4cac4e1a72ff..af419012d77d 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -2,29 +2,9 @@ #ifndef _LINUX_BITOPS_H #define _LINUX_BITOPS_H #include +#include -#ifdef __KERNEL__ -#define BIT(nr) (1UL << (nr)) -#define BIT_ULL(nr) (1ULL << (nr)) -#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) -#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) -#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) -#define BITS_PER_BYTE 8 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) -#endif - -/* - * Create a contiguous bitmask starting at bit position @l and ending at - * position @h. For example - * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. - */ -#define GENMASK(h, l) \ - (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) - -#define GENMASK_ULL(h, l) \ - (((~0ULL) - (1ULL << (l)) + 1) & \ - (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) extern unsigned int __sw_hweight8(unsigned int w); extern unsigned int __sw_hweight16(unsigned int w); diff --git a/include/linux/bits.h b/include/linux/bits.h new file mode 100644 index 000000000000..2b7b532c1d51 --- /dev/null +++ b/include/linux/bits.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_BITS_H +#define __LINUX_BITS_H +#include + +#define BIT(nr) (1UL << (nr)) +#define BIT_ULL(nr) (1ULL << (nr)) +#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +#define BIT_ULL_MASK(nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) +#define BIT_ULL_WORD(nr) ((nr) / BITS_PER_LONG_LONG) +#define BITS_PER_BYTE 8 + +/* + * Create a contiguous bitmask starting at bit position @l and ending at + * position @h. For example + * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. + */ +#define GENMASK(h, l) \ + (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +#define GENMASK_ULL(h, l) \ + (((~0ULL) - (1ULL << (l)) + 1) & \ + (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + +#endif /* __LINUX_BITS_H */