From patchwork Fri Aug 30 13:17:31 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: 2852016 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 08200C0AB5 for ; Fri, 30 Aug 2013 13:21:58 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A6F5920546 for ; Fri, 30 Aug 2013 13:21:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F4A920535 for ; Fri, 30 Aug 2013 13:21:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755630Ab3H3NVj (ORCPT ); Fri, 30 Aug 2013 09:21:39 -0400 Received: from e7.ny.us.ibm.com ([32.97.182.137]:35604 "EHLO e7.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756488Ab3H3NVh (ORCPT ); Fri, 30 Aug 2013 09:21:37 -0400 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 30 Aug 2013 09:21:36 -0400 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 30 Aug 2013 09:21:34 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 6E76EC90048; Fri, 30 Aug 2013 09:21:33 -0400 (EDT) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by b01cxnp22036.gho.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r7UDLXD89109662; Fri, 30 Aug 2013 13:21:33 GMT Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r7UDLQ88029952; Fri, 30 Aug 2013 10:21:32 -0300 Received: from srivatsabhat.in.ibm.com ([9.79.248.196]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id r7UDLGm7029331; Fri, 30 Aug 2013 10:21:18 -0300 From: "Srivatsa S. Bhat" Subject: [RFC PATCH v3 12/35] bitops: Document the difference in indexing between fls() and __fls() To: akpm@linux-foundation.org, mgorman@suse.de, hannes@cmpxchg.org, tony.luck@intel.com, matthew.garrett@nebula.com, dave@sr71.net, riel@redhat.com, arjan@linux.intel.com, srinivas.pandruvada@linux.intel.com, willy@linux.intel.com, kamezawa.hiroyu@jp.fujitsu.com, lenb@kernel.org, rjw@sisk.pl Cc: gargankita@gmail.com, paulmck@linux.vnet.ibm.com, svaidy@linux.vnet.ibm.com, andi@firstfloor.org, isimatu.yasuaki@jp.fujitsu.com, santosh.shilimkar@ti.com, kosaki.motohiro@gmail.com, srivatsa.bhat@linux.vnet.ibm.com, linux-pm@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Date: Fri, 30 Aug 2013 18:47:31 +0530 Message-ID: <20130830131727.4947.86874.stgit@srivatsabhat.in.ibm.com> In-Reply-To: <20130830131221.4947.99764.stgit@srivatsabhat.in.ibm.com> References: <20130830131221.4947.99764.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: 13083013-5806-0000-0000-000022964BFF Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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) {