From patchwork Wed May 15 10:54:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 164273 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp613842ili; Wed, 15 May 2019 04:12:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqxMtBmARjWyYju/HfAXsjR/wf6GaG22HWYVauMGqs1jH6U8az/OwseiUzrEKGLAkGU44Vmh X-Received: by 2002:a63:ed16:: with SMTP id d22mr42620915pgi.35.1557918753066; Wed, 15 May 2019 04:12:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557918753; cv=none; d=google.com; s=arc-20160816; b=udjRcYJumJW5LrGJK5AOR26nZZ1PrqtRJRRwZ5WlizkzsGkP2/lnyHmtiyh58/lMrS cmfrD5LEL0ZJVauhDbxF8qEEKDKIdXKJ7dqUmIknH6Tb/EHbEKspN+qzrq2d2ng/8X9T V+9/2naD7pbD9VzrMHRqD4J0lHGukdZwhlwZoUV4M6ovuElRWV0odSo12lRoqkmHClgu H881F5VJTw5L4fhS8YGLJfkp05MCSHagxBJ9+caYZhINkd0b5qNywa/rGRkujCYbCwHe Kb5jmF89JD4elaOv+EMaGHArNUT/RQJhkdHmg4oaCcLjj5+U2WL436vz6qLclD72iYTn R2sw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YSLj8SQdLKlekXkjBlppjsCWdmXRlVdUhhmZxTu/zBs=; b=wF/64UC1wOYuFVnO56NDbYtkFYqz1LhJ0j8xHMgrOj3RH3IHAlzDz5KVre4LFXigwv qyAKjGvQc9qX61Q1klmhdbXnT86lf7nLD2kHFdrbIdxP4DThaZtb9ud6gsG5I44P7Gv7 imrXMF0Q1EJTilWkHqvM1J91bXMDXUKXVghBLlX7oYDzEVzzChgSy0/Ma92ilhSn099u /DI9s4DzB2ZTVWf1IEQSkOnvuAZRUCIQoQtIXL0/0xzj3YBKkf2DYtZImXE551JT8NWP xWm69xVYEMwDRLvtLYcLnq/Ji/qF3lSu7j3O51REyBt4ANcOWAwNXQTlL7SwzzxnWP/E CdXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kNA4xfyO; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 t5si1594777pgj.258.2019.05.15.04.12.31; Wed, 15 May 2019 04:12:33 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kNA4xfyO; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728852AbfEOLJ6 (ORCPT + 14 others); Wed, 15 May 2019 07:09:58 -0400 Received: from mail.kernel.org ([198.145.29.99]:43228 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729315AbfEOLJx (ORCPT ); Wed, 15 May 2019 07:09:53 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 9BF0C20843; Wed, 15 May 2019 11:09:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557918592; bh=JbPRabLIMrTvWdkn5zLLgPu/FCNDuIM6k0f73dNLetE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kNA4xfyOThsK3VpryKIMa7jh4tPXKqEnprUBb9JmyC43O5x61N2oeW3onxP64PUvC 2wkXzZ3jbgrdNo3yddpGMnmm4Xa4Cu8nOpghXv3gajrai+juinmlA3006K6lyZJUcR oMlAJdoWyumrmlu0roYlOJiLX62EZI8P+nvxU1EU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , "Peter Zijlstra (Intel)" , Linus Torvalds , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, yamada.masahiro@socionext.com, Ingo Molnar , Ben Hutchings Subject: [PATCH 4.4 190/266] locking/atomics, asm-generic: Move some macros from to a new file Date: Wed, 15 May 2019 12:54:57 +0200 Message-Id: <20190515090729.368808952@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190515090722.696531131@linuxfoundation.org> References: <20190515090722.696531131@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Will Deacon commit 8bd9cb51daac89337295b6f037b0486911e1b408 upstream. In preparation for implementing the asm-generic atomic bitops in terms of atomic_long_*(), we need to prevent implementations from pulling in . 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, . Signed-off-by: Will Deacon Acked-by: Peter Zijlstra (Intel) Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Cc: linux-arm-kernel@lists.infradead.org Cc: yamada.masahiro@socionext.com Link: https://lore.kernel.org/lkml/1529412794-17720-4-git-send-email-will.deacon@arm.com Signed-off-by: Ingo Molnar Signed-off-by: Thomas Gleixner Signed-off-by: Ben Hutchings Signed-off-by: Greg Kroah-Hartman --- include/linux/bitops.h | 22 +--------------------- include/linux/bits.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) create mode 100644 include/linux/bits.h --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -1,29 +1,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); --- /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 */