From: Arend van Spriel Date: Mon, 9 May 2011 14:33:27 +0000 (+0200) Subject: staging: brcm80211: make use of fls bit operation in wlc_phy_compute_dB X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=b8fbc3928cce0c8fa7c01afc33ddef02062504e1;p=openwrt%2Fstaging%2Fblogic.git staging: brcm80211: make use of fls bit operation in wlc_phy_compute_dB wlc_phy_compute_dB converts absolute power value to dB implementing a fixed point calculation for 10*log10(x). It does this by determining the most significant bit for value x. This can be done using the fls() bit operation, which has arch specific and possibly more efficient implementation. Cc: devel@linuxdriverproject.org Cc: linux-wireless@vger.kernel.org Reviewed-by: Roland Vossen Reviewed-by: Henry Ptasinski Reviewed-by: Brett Rudley Signed-off-by: Arend van Spriel Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c index 7837c73023fc..9c2ab38c1f12 100644 --- a/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c +++ b/drivers/staging/brcm80211/brcmsmac/phy/wlc_phy_cmn.c @@ -18,10 +18,12 @@ #include #include -#include +#include #include #include #include + +#include #include #include #include @@ -2746,20 +2748,15 @@ s8 lcnphy_gain_index_offset_for_pkt_rssi[] = { void wlc_phy_compute_dB(u32 *cmplx_pwr, s8 *p_cmplx_pwr_dB, u8 core) { - u8 shift_ct, lsb, msb, secondmsb, i; + u8 msb, secondmsb, i; u32 tmp; for (i = 0; i < core; i++) { + secondmsb = 0; tmp = cmplx_pwr[i]; - shift_ct = msb = secondmsb = 0; - while (tmp != 0) { - tmp = tmp >> 1; - shift_ct++; - lsb = (u8) (tmp & 1); - if (lsb == 1) - msb = shift_ct; - } - secondmsb = (u8) ((cmplx_pwr[i] >> (msb - 1)) & 1); + msb = fls(tmp); + if (msb) + secondmsb = (u8) ((tmp >> (--msb - 1)) & 1); p_cmplx_pwr_dB[i] = (s8) (3 * msb + 2 * secondmsb); } }