From patchwork Tue Jun 19 12:53:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Deacon X-Patchwork-Id: 139110 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5170164lji; Tue, 19 Jun 2018 05:52:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKmbYiuYcw707JEbORPULPyG/nXR2YsZ8E5GWizGLKPMug3Bv7zVSLCEmE5WkJCZT+x6t8K X-Received: by 2002:a17:902:280b:: with SMTP id e11-v6mr18740144plb.298.1529412770064; Tue, 19 Jun 2018 05:52:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529412770; cv=none; d=google.com; s=arc-20160816; b=QZFyRquqAhg7gevGG92pshewQSPhgnyXl4c/7JhoxvTQ2ENL5JQwgFsR9hYQDFXQEM DZBDoItl8D44mMpXaXGLhV97kgt5ANBFbCG14hMch/T6KxmHulkihKErWa/YptxbE+hl gRj+zxwBm4zzSs7wD2P5TB+T6ICVtvXD0XZ1LVTqtc1ZuqeIrsuxQwF7ZgygBB90UfR1 AlQnDsox2T3ghxh94KY8HMRDPivK6r94xqtl5GiTenE9QysbGSpnpA9ObiHTP0EHhfkj iJ7iMymt7Jw3ZaEzJdNwtb/lkiuieQL2M+jdXp4uMi4PtPCsgplFXWm4FxvKdVwJP98F WANQ== 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=Y5nJSRHCmQMhRLBNBZo6Pv7oyT/JSD1eVdxM3H5iH1c=; b=maEc00BHrE/h6qRP1UbJOuPKLuWPjNPl2bbUK2Z2BZaS0cOEzQK0SvedwRTjW6XxtY fNUhJgt1KbYDr+xqZ2Y7QESJbDRk0bAEpMlvbEkRxCFgT9cfyynIiRijH/+Cw/OKbgDg Nht/cWOxC0awTMv6zLdeAVPe4bl8jXaTiBZ1S4YHUwwxGMJzZpiPvUt/mYcr4unU0lyW 9T2+Ynqli6O39GyJIRIzGYso1E9cLoFLQpmEhoxaxL8G0q2zEe+kq42Z0va+fL5/Faxg RNypPOA4ikahV5KzWcuSPkMpY6GiHL6XYYQwqb9quXENSrWBNCJvEzQ5c1dcJZCHyJcs Z5Mw== 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 k91-v6si17768945pld.248.2018.06.19.05.52.49; Tue, 19 Jun 2018 05:52:50 -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 S937913AbeFSMwr (ORCPT + 30 others); Tue, 19 Jun 2018 08:52:47 -0400 Received: from foss.arm.com ([217.140.101.70]:49316 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S937849AbeFSMwk (ORCPT ); Tue, 19 Jun 2018 08:52:40 -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 47DAC15BF; Tue, 19 Jun 2018 05:52:40 -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 19E453F557; Tue, 19 Jun 2018 05:52:40 -0700 (PDT) Received: by edgewater-inn.cambridge.arm.com (Postfix, from userid 1000) id ABBBC1AE3638; Tue, 19 Jun 2018 13:53:15 +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: [RESEND PATCH v2 3/9] asm-generic: Move some macros from linux/bitops.h to a new bits.h file Date: Tue, 19 Jun 2018 13:53:08 +0100 Message-Id: <1529412794-17720-4-git-send-email-will.deacon@arm.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1529412794-17720-1-git-send-email-will.deacon@arm.com> References: <1529412794-17720-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 Acked-by: Peter Zijlstra (Intel) 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 Signed-off-by: Chris Wilson Reviewed-by: Jani Nikula Signed-off-by: Andrew Morton 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 */