lkml.org 
[lkml]   [2022]   [Aug]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH 1/3] staging: r8188eu: use ffs() in phy_CalculateBitShift()
Date
Use ffs() in phy_CalculateBitShift() to simplify the function and
improve readability.

Signed-off-by: Michael Straube <straube.linux@gmail.com>
---
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
index dea6d915a1f4..3d8fcc1f0b6a 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
@@ -25,13 +25,9 @@
*/
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;
}

/**
--
2.37.1
\
 
 \ /
  Last update: 2022-08-06 08:10    [W:1.451 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site