lkml.org 
[lkml]   [2014]   [Jan]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v2] Staging: lustre: Use of fls to find last set bit
From
Date
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.




\
 
 \ /
  Last update: 2014-01-11 21:21    [W:0.067 / U:0.976 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site