From patchwork Wed Aug 7 09:06:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 18824 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f69.google.com (mail-qa0-f69.google.com [209.85.216.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 82960246A4 for ; Wed, 7 Aug 2013 09:06:29 +0000 (UTC) Received: by mail-qa0-f69.google.com with SMTP id bv4sf2239391qab.4 for ; Wed, 07 Aug 2013 02:06:29 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=VN1f0+l/JpFcN25Y8BACLO8KNlR7Ba4CGWath8o+vxA=; b=DasUdsAqdPwaZzsTAkAwuG2d5D4oehjgCTGJ9SsziY6Ke+KSjlrtFSewhcRJa3u8CM GDW8ZiMBhS8AmpwXgn+IPE38ZyYHuoZpEqZg7Kpn6siGq/XqJ7qoO0Q9Qr+2qP9C6j7s RYlcUg2JnZ3l+BVWte4K5VPvKDQ+414Mp+OER5BBuNFDggRFzc5ZjgivvWII1YtSDtJG Lq4E2yhFVz15Eomc4X5luiKii2BME1udGav5LgZivQGbOtl4EyrOh8o12PpBovQnM2N5 TSYZO8twdjF4JZp10uCgBvS8PHTPlKEozgZvwmwTXe2R/HMk96/D/vjjlrLywyTTFVtS MImQ== X-Received: by 10.236.135.66 with SMTP id t42mr1040512yhi.36.1375866389067; Wed, 07 Aug 2013 02:06:29 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.47.82 with SMTP id b18ls583389qen.53.gmail; Wed, 07 Aug 2013 02:06:29 -0700 (PDT) X-Received: by 10.52.94.78 with SMTP id da14mr593140vdb.28.1375866388973; Wed, 07 Aug 2013 02:06:28 -0700 (PDT) Received: from mail-vb0-f47.google.com (mail-vb0-f47.google.com [209.85.212.47]) by mx.google.com with ESMTPS id vf5si1286408vdc.57.2013.08.07.02.06.28 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Aug 2013 02:06:28 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.47; Received: by mail-vb0-f47.google.com with SMTP id h10so1558157vbh.34 for ; Wed, 07 Aug 2013 02:06:28 -0700 (PDT) X-Gm-Message-State: ALoCoQlP1iNHJRoFiLr7BEkAbBIywXYXY5B0VZ9cvxxxLkiIMHpRvOc5aTgOR//UjLTYZvAtLPPQ X-Received: by 10.58.187.4 with SMTP id fo4mr698760vec.55.1375866388827; Wed, 07 Aug 2013 02:06:28 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.221.11.8 with SMTP id pc8csp190176vcb; Wed, 7 Aug 2013 02:06:28 -0700 (PDT) X-Received: by 10.112.56.197 with SMTP id c5mr1174078lbq.84.1375866387416; Wed, 07 Aug 2013 02:06:27 -0700 (PDT) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com [209.85.217.181]) by mx.google.com with ESMTPS id g2si3201499lbd.114.2013.08.07.02.06.26 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 07 Aug 2013 02:06:27 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.217.181 is neither permitted nor denied by best guess record for domain of linus.walleij@linaro.org) client-ip=209.85.217.181; Received: by mail-lb0-f181.google.com with SMTP id o10so1298301lbi.26 for ; Wed, 07 Aug 2013 02:06:26 -0700 (PDT) X-Received: by 10.152.116.76 with SMTP id ju12mr985135lab.54.1375866386532; Wed, 07 Aug 2013 02:06:26 -0700 (PDT) Received: from localhost.localdomain (c83-249-208-124.bredband.comhem.se. [83.249.208.124]) by mx.google.com with ESMTPSA id f8sm2784100lbf.5.2013.08.07.02.06.24 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 07 Aug 2013 02:06:25 -0700 (PDT) From: Linus Walleij To: linux-kernel@vger.kernel.org Cc: Linus Walleij , Akinobu Mita Subject: [PATCH] bitops: move BITS() macro to the bitops file Date: Wed, 7 Aug 2013 11:06:19 +0200 Message-Id: <1375866379-27504-1-git-send-email-linus.walleij@linaro.org> X-Mailer: git-send-email 1.8.1.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: linus.walleij@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.212.47 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This macro was invented by Mattias Nilsson for the usecase where you want to set a sequence of bits inside a n-bit word, while leaving the head and tail of the sequence all zeroes. For example: #include u16 mask = BITS(4, 12); Yields a mask like this: 0001111111110000 This patch moves the construct out of the MFD PRCMU driver and make it available for common use, after noticing in a review or two that it would be useful for others. Cc: Akinobu Mita Signed-off-by: Linus Walleij --- drivers/mfd/dbx500-prcmu-regs.h | 2 -- include/linux/bitops.h | 1 + 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/mfd/dbx500-prcmu-regs.h b/drivers/mfd/dbx500-prcmu-regs.h index 4f6f0fa..906e75e 100644 --- a/drivers/mfd/dbx500-prcmu-regs.h +++ b/drivers/mfd/dbx500-prcmu-regs.h @@ -13,8 +13,6 @@ #ifndef __DB8500_PRCMU_REGS_H #define __DB8500_PRCMU_REGS_H -#define BITS(_start, _end) ((BIT(_end) - BIT(_start)) + BIT(_end)) - #define PRCM_ACLK_MGT (0x004) #define PRCM_SVAMMCSPCLK_MGT (0x008) #define PRCM_SIAMMDSPCLK_MGT (0x00C) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index a3b6b82..1f9d78b 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -6,6 +6,7 @@ #define BIT(nr) (1UL << (nr)) #define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG)) #define BIT_WORD(nr) ((nr) / BITS_PER_LONG) +#define BITS(_start, _end) ((BIT(_end) - BIT(_start)) + BIT(_end)) #define BITS_PER_BYTE 8 #define BITS_TO_LONGS(nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) #endif