staging: rtl8192e: Simplify _rtl92e_calculate_bit_shift
authorMateusz Kulikowski <mateusz.kulikowski@gmail.com>
Sun, 20 Sep 2015 19:04:32 +0000 (21:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Sep 2015 02:26:07 +0000 (04:26 +0200)
Use ffs instead of iteration. Behaviour of function doesn't change.

Signed-off-by: Mateusz Kulikowski <mateusz.kulikowski@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/rtl8192e/rtl8192e/r8192E_phy.c

index b3a10f9f01cdcd6ecc3586142bf6043cc39919f6..0b407feb54073348a3a551506723a4553ea89f54 100644 (file)
@@ -13,6 +13,7 @@
  * wlanfae <wlanfae@realtek.com>
 ******************************************************************************/
 
+#include <linux/bitops.h>
 #include "rtl_core.h"
 #include "r8192E_hw.h"
 #include "r8192E_phyreg.h"
@@ -50,13 +51,9 @@ static void _rtl92e_phy_rf_fw_write(struct net_device *dev,
 
 static u32 _rtl92e_calculate_bit_shift(u32 dwBitMask)
 {
-       u32 i;
-
-       for (i = 0; i <= 31; i++) {
-               if (((dwBitMask >> i) & 0x1) == 1)
-                       break;
-       }
-       return i;
+       if (!dwBitMask)
+               return 32;
+       return ffs(dwBitMask) - 1;
 }
 
 u8 rtl92e_is_legal_rf_path(struct net_device *dev, u32 eRFPath)