From patchwork Fri Jan 13 15:53:20 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 135912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from merlin.infradead.org (merlin.infradead.org [IPv6:2001:4978:20e::2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 25A3FB6F67 for ; Sat, 14 Jan 2012 02:55:15 +1100 (EST) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1RljRv-00016u-Ng; Fri, 13 Jan 2012 15:53:51 +0000 Received: from mail-iy0-f177.google.com ([209.85.210.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1RljRs-000161-03 for linux-mtd@lists.infradead.org; Fri, 13 Jan 2012 15:53:48 +0000 Received: by iakl21 with SMTP id l21so5214403iak.36 for ; Fri, 13 Jan 2012 07:53:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=7Vrv38XJC60Zq1aKiWlt5lnqbBqA2xZCn8KlrMfFrIg=; b=Fi6uxcmflhSaBPgrcSokhYQKkMr4OrxITeC9CX1cdcVS6JSjO6y5qfEu8VXJqF9uPf //FZCCNbe4eti+X7wYfUam12pqlpCPHddJJ0JnYbGVkx388cKYl/21B+Ly/zf1T4w9Ik QtNIF1oI87kFBIHxhxWZjYB4YYNwd69hE4T1c= Received: by 10.50.178.71 with SMTP id cw7mr1398401igc.0.1326470025878; Fri, 13 Jan 2012 07:53:45 -0800 (PST) Received: from localhost.localdomain (p11175-adsau04yokonib2-acca.kanagawa.ocn.ne.jp. [220.104.206.175]) by mx.google.com with ESMTPS id py4sm7330114igc.2.2012.01.13.07.53.39 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 13 Jan 2012 07:53:45 -0800 (PST) From: Akinobu Mita To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: [PATCH 3/7] bitops: introduce list_for_each_clear_bit Date: Sat, 14 Jan 2012 00:53:20 +0900 Message-Id: <1326470004-10096-4-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1326470004-10096-1-git-send-email-akinobu.mita@gmail.com> References: <1326470004-10096-1-git-send-email-akinobu.mita@gmail.com> X-Spam-Note: CRM114 invocation failed X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (akinobu.mita[at]gmail.com) -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.210.177 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: linux-s390@vger.kernel.org, linux-usb@vger.kernel.org, Robert Richter , x86@kernel.org, Heiko Carstens , Akinobu Mita , Ingo Molnar , linux-mtd@lists.infradead.org, "H. Peter Anvin" , Martin Schwidefsky , linux390@de.ibm.com, Thomas Gleixner , David Woodhouse X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-mtd-bounces@lists.infradead.org Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Introduce list_for_each_clear_bit() and list_for_each_clear_bit_from(). They are similar to for_each_set_bit() and list_for_each_set_bit_from(), but they iterate over all the cleared bits in a memory region. Signed-off-by: Akinobu Mita Cc: Robert Richter Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: David Woodhouse Cc: linux-mtd@lists.infradead.org Cc: Martin Schwidefsky Cc: Heiko Carstens Cc: linux390@de.ibm.com Cc: linux-s390@vger.kernel.org Cc: linux-usb@vger.kernel.org --- include/linux/bitops.h | 11 +++++++++++ 1 files changed, 11 insertions(+), 0 deletions(-) diff --git a/include/linux/bitops.h b/include/linux/bitops.h index 15ad702..c8a0d65 100644 --- a/include/linux/bitops.h +++ b/include/linux/bitops.h @@ -32,6 +32,17 @@ extern unsigned long __sw_hweight64(__u64 w); (bit) < (size); \ (bit) = find_next_bit((addr), (size), (bit) + 1)) +#define for_each_clear_bit(bit, addr, size) \ + for ((bit) = find_first_zero_bit((addr), (size)); \ + (bit) < (size); \ + (bit) = find_next_zero_bit((addr), (size), (bit) + 1)) + +/* same as for_each_clear_bit() but use bit as value to start with */ +#define for_each_clear_bit_from(bit, addr, size) \ + for ((bit) = find_next_zero_bit((addr), (size), (bit)); \ + (bit) < (size); \ + (bit) = find_next_zero_bit((addr), (size), (bit) + 1)) + static __inline__ int get_bitmask_order(unsigned int count) { int order;