staging: r8188eu: use ffs() in phy_CalculateBitShift()
authorMichael Straube <straube.linux@gmail.com>
Sat, 6 Aug 2022 06:09:27 +0000 (08:09 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 16 Aug 2022 13:16:16 +0000 (15:16 +0200)
Use ffs() in phy_CalculateBitShift() to simplify the function and
improve readability.

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150
Signed-off-by: Michael Straube <straube.linux@gmail.com>
Link: https://lore.kernel.org/r/20220806060929.11022-2-straube.linux@gmail.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c

index dea6d915a1f4042d8e0c5e99b4f6023b78a28f0b..3d8fcc1f0b6afdefff0b805cb484ef11f8623557 100644 (file)
 */
 static u32 phy_CalculateBitShift(u32 BitMask)
 {
-       u32 i;
+       u32 i = ffs(BitMask);
 
-       for (i = 0; i <= 31; i++) {
-               if (((BitMask >> i) & 0x1) == 1)
-                       break;
-       }
-       return i;
+       return i ? i - 1 : 32;
 }
 
 /**