mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Monam Agarwal <monamagarwal123@gmail.com>
Cc: gregkh@linuxfoundation.org, andreas.dilger@intel.com,
	peter.p.waskiewicz.jr@intel.com, tao.peng@emc.com,
	devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] Staging: lustre: Use of fls to find last set bit
Date: Sat, 11 Jan 2014 12:02:48 -0800	[thread overview]
Message-ID: <1389470568.2537.81.camel@joe-AO722> (raw)
In-Reply-To: <1389468763-25662-1-git-send-email-monamagarwal123@gmail.com>

On Sun, 2014-01-12 at 01:02 +0530, Monam Agarwal wrote:
> This introduces fls in lustre/ldlm/ldlm_extent.c 
> to find the last set bit. 
[]
> Signed-off-by: Monam Agarwal <monamagarwal123@gmail.com>
> ---
> Changes since v1:
> *Incorrect commit message
> *Use of fls function
[]
> diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c b/drivers/staging/lustre/lustre/ldlm/ldlm_extent.c
[]
> @@ -150,10 +150,12 @@ struct ldlm_interval *ldlm_interval_detach(struct ldlm_lock *l)
>  static inline int lock_mode_to_index(ldlm_mode_t mode)
>  {
>  	int index;
> +	int len;
>  
>  	LASSERT(mode != 0);
>  	LASSERT(IS_PO2(mode));
> -	for (index = -1; mode; index++, mode >>= 1) ;
> +	len = fls(mode);
> +	index = len-1;

There's no need for len at all.

	index = fls(mode) - 1;

would be fine.



  reply	other threads:[~2014-01-11 20:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-11 11:41 [PATCH 1/2] Staging: lustre: Removal of Unnecessary white spaces Monam Agarwal
2014-01-11 17:23 ` Joe Perches
2014-01-11 19:32 ` [PATCH v2] Staging: lustre: Use of fls to find last set bit Monam Agarwal
2014-01-11 20:02   ` Joe Perches [this message]
2014-01-11 20:15   ` [PATCH v3] " Monam Agarwal
2014-01-13  8:21     ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1389470568.2537.81.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=andreas.dilger@intel.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=monamagarwal123@gmail.com \
    --cc=peter.p.waskiewicz.jr@intel.com \
    --cc=tao.peng@emc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®