staging: r8188eu: clean up phy_CalculateBitShift()
cover staging: r8188eu: clean up phy_CalculateBitShift()
This series simplifies the function phy_CalculateBitShift() and cleans up coding style issues in that function.
Tested on x86_64 with Inter-Tech DMG-02.
Michael Straube (3):
staging: r8188eu: use ffs() in phy_CalculateBitShift()
staging: r8188eu: avoid camel case in phy_CalculateBitShift()
staging: r8188eu: clean up comment for phy_calculate_bit_shift()
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-)
Signature · 1 line
2.37.1
PATCH 1/3 staging: r8188eu: use ffs() in phy_CalculateBitShift()
Use ffs() in phy_CalculateBitShift() to simplify the function and improve readability.
--- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +2 -6
@@ -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 ; }/**
Signature · 1 line
2.37.1
PATCH 2/3 staging: r8188eu: avoid camel case in phy_CalculateBitShift()
In reply to Michael StraubeRename the function phy_CalculateBitShift() and its parameter BitMask to avoid camel case.
phy_CalculateBitShift -> phy_calculate_bit_shift
BitMask -> bitmask
--- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +6 -6
@@ -23,9 +23,9 @@* Output: none * Return: u32 Return the shift bit bit position of the mask */ -static u32 phy_CalculateBitShift (u32 BitMask) +static u32 phy_calculate_bit_shift (u32 bitmask) { -u32 i =ffs (BitMask); +u32 i =ffs (bitmask);return i ? i -1 :32 ; }
@@ -58,7 +58,7 @@ rtl8188e_PHY_QueryBBReg(if (res)return 0 ; - BitShift =phy_CalculateBitShift (BitMask); + BitShift =phy_calculate_bit_shift (BitMask); ReturnValue = (OriginalValue & BitMask) >> BitShift;return ReturnValue; }
@@ -91,7 +91,7 @@ void rtl8188e_PHY_SetBBReg(struct adapter *Adapter, u32 RegAddr, u32 BitMask, u3if (res)return ; - BitShift =phy_CalculateBitShift (BitMask); + BitShift =phy_calculate_bit_shift (BitMask); Data = ((OriginalValue & (~BitMask)) | (Data << BitShift)); }
@@ -263,7 +263,7 @@ u32 rtl8188e_PHY_QueryRFReg(struct adapter *Adapter, u32 RegAddr, u32 BitMask) Original_Value =phy_RFSerialRead (Adapter, RegAddr); - BitShift =phy_CalculateBitShift (BitMask); + BitShift =phy_calculate_bit_shift (BitMask); Readback_Value = (Original_Value & BitMask) >> BitShift;return Readback_Value; }
@@ -298,7 +298,7 @@ rtl8188e_PHY_SetRFReg(/* RF data is 12 bits only */ if (BitMask != bRFRegOffsetMask) { Original_Value =phy_RFSerialRead (Adapter, RegAddr); - BitShift =phy_CalculateBitShift (BitMask); + BitShift =phy_calculate_bit_shift (BitMask); Data = ((Original_Value & (~BitMask)) | (Data << BitShift)); }
Signature · 1 line
2.37.1
PATCH 3/3 staging: r8188eu: clean up comment for phy_calculate_bit_shift()
In reply to Michael StraubeClean up the comment for function phy_calculate_bit_shift().
--- drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/staging/r8188eu/hal/rtl8188e_phycfg.c +1 -11
@@ -12,17 +12,7 @@/* 1. BB register R/W API */ /* */ -/** -* Function: phy_CalculateBitShift -* -* OverView: Get shifted position of the BitMask -* -* Input: -* u32 BitMask, -* -* Output: none -* Return: u32 Return the shift bit bit position of the mask -*/ +/* Get shifted position of the bit mask */ static u32 phy_calculate_bit_shift (u32 bitmask) {u32 i =ffs (bitmask);
Signature · 1 line
2.37.1
Quoted 5 lines · Michael Straube
This series simplifies the function
phy_CalculateBitShift()and cleans up coding style issues in that function.Tested on
x86_64with Inter-Tech DMG-02.
Quoted 8 lines
Michael Straube (3):
staging: r8188eu: useffs()inphy_CalculateBitShift()
staging: r8188eu: avoid camel case inphy_CalculateBitShift()
staging: r8188eu: clean up comment forphy_calculate_bit_shift()drivers/staging/r8188eu/hal/rtl8188e_phycfg.c | 30 +++++-------------- 1 file changed, 8 insertions(+), 22 deletions(-)