From patchwork Tue Apr 9 21:47:38 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Srivatsa S. Bhat" X-Patchwork-Id: 2417811 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id F1BB73FD8C for ; Tue, 9 Apr 2013 21:52:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S936527Ab3DIVuX (ORCPT ); Tue, 9 Apr 2013 17:50:23 -0400 Received: from e28smtp04.in.ibm.com ([122.248.162.4]:57258 "EHLO e28smtp04.in.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935985Ab3DIVuU (ORCPT ); Tue, 9 Apr 2013 17:50:20 -0400 Received: from /spool/local by e28smtp04.in.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 10 Apr 2013 03:16:22 +0530 Received: from d28dlp01.in.ibm.com (9.184.220.126) by e28smtp04.in.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 10 Apr 2013 03:16:19 +0530 Received: from d28relay04.in.ibm.com (d28relay04.in.ibm.com [9.184.220.61]) by d28dlp01.in.ibm.com (Postfix) with ESMTP id B46F2E0053; Wed, 10 Apr 2013 03:22:03 +0530 (IST) Received: from d28av04.in.ibm.com (d28av04.in.ibm.com [9.184.220.66]) by d28relay04.in.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r39LoAHm57475072; Wed, 10 Apr 2013 03:20:11 +0530 Received: from d28av04.in.ibm.com (loopback [127.0.0.1]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r39LoAkd000460; Wed, 10 Apr 2013 07:50:14 +1000 Received: from srivatsabhat.in.ibm.com ([9.79.251.39]) by d28av04.in.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r39Lo7Hq000379; Wed, 10 Apr 2013 07:50:08 +1000 From: "Srivatsa S. Bhat" Subject: [RFC PATCH v2 08/15] bitops: Document the difference in indexing between fls() and __fls() To: akpm@linux-foundation.org, mgorman@suse.de, matthew.garrett@nebula.com, dave@sr71.net, rientjes@google.com, riel@redhat.com, arjan@linux.intel.com, srinivas.pandruvada@linux.intel.com, maxime.coquelin@stericsson.com, loic.pallardy@stericsson.com, kamezawa.hiroyu@jp.fujitsu.com, lenb@kernel.org, rjw@sisk.pl Cc: gargankita@gmail.com, paulmck@linux.vnet.ibm.com, amit.kachhap@linaro.org, svaidy@linux.vnet.ibm.com, andi@firstfloor.org, wujianguo@huawei.com, kmpark@infradead.org, thomas.abraham@linaro.org, santosh.shilimkar@ti.com, srivatsa.bhat@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Wed, 10 Apr 2013 03:17:38 +0530 Message-ID: <20130409214735.4500.29838.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130409214443.4500.44168.stgit@srivatsabhat.in.ibm.com> References: <20130409214443.4500.44168.stgit@srivatsabhat.in.ibm.com> User-Agent: StGIT/0.14.3 MIME-Version: 1.0 X-TM-AS-MML: No X-Content-Scanned: Fidelis XPS MAILER x-cbid: 13040921-5564-0000-0000-0000076FA102 Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org fls() indexes the bits starting with 1, ie., from 1 to BITS_PER_LONG whereas __fls() uses a zero-based indexing scheme (0 to BITS_PER_LONG - 1). Add comments to document this important difference. Signed-off-by: Srivatsa S. Bhat --- arch/x86/include/asm/bitops.h | 4 ++++ include/asm-generic/bitops/__fls.h | 5 +++++ 2 files changed, 9 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-pm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/x86/include/asm/bitops.h b/arch/x86/include/asm/bitops.h index 6dfd019..25e6fdc 100644 --- a/arch/x86/include/asm/bitops.h +++ b/arch/x86/include/asm/bitops.h @@ -380,6 +380,10 @@ static inline unsigned long ffz(unsigned long word) * @word: The word to search * * Undefined if no set bit exists, so code should check against 0 first. + * + * Note: __fls(x) is equivalent to fls(x) - 1. That is, __fls() uses + * a zero-based indexing scheme (0 to BITS_PER_LONG - 1), where + * __fls(1) = 0, __fls(2) = 1, and so on. */ static inline unsigned long __fls(unsigned long word) { diff --git a/include/asm-generic/bitops/__fls.h b/include/asm-generic/bitops/__fls.h index a60a7cc..ae908a5 100644 --- a/include/asm-generic/bitops/__fls.h +++ b/include/asm-generic/bitops/__fls.h @@ -8,6 +8,11 @@ * @word: the word to search * * Undefined if no set bit exists, so code should check against 0 first. + * + * Note: __fls(x) is equivalent to fls(x) - 1. That is, __fls() uses + * a zero-based indexing scheme (0 to BITS_PER_LONG - 1), where + * __fls(1) = 0, __fls(2) = 1, and so on. + * */ static __always_inline unsigned long __fls(unsigned long word) {