linux-staging.lists.linux.dev archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift()
@ 2022-08-06  6:09 Michael Straube
  2022-08-06  6:09 ` [PATCH 1/3] staging: r8188eu: use ffs() in phy_CalculateBitShift() Michael Straube
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Michael Straube @ 2022-08-06  6:09 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

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(-)

-- 
2.37.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] staging: r8188eu: use ffs() in phy_CalculateBitShift()
  2022-08-06  6:09 [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift() Michael Straube
@ 2022-08-06  6:09 ` Michael Straube
  2022-08-06  6:09 ` [PATCH 2/3] staging: r8188eu: avoid camel case " Michael Straube
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Straube @ 2022-08-06  6:09 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

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


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] staging: r8188eu: avoid camel case in phy_CalculateBitShift()
  2022-08-06  6:09 [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift() Michael Straube
  2022-08-06  6:09 ` [PATCH 1/3] staging: r8188eu: use ffs() in phy_CalculateBitShift() Michael Straube
@ 2022-08-06  6:09 ` Michael Straube
  2022-08-06  6:09 ` [PATCH 3/3] staging: r8188eu: clean up comment for phy_calculate_bit_shift() Michael Straube
  2022-08-06 18:18 ` [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift() Philipp Hortmann
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Straube @ 2022-08-06  6:09 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Rename the function phy_CalculateBitShift() and its parameter BitMask
to avoid camel case.

phy_CalculateBitShift -> phy_calculate_bit_shift
BitMask -> bitmask

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

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
index 3d8fcc1f0b6a..e9e24efabd76 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
@@ -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, u3
 		if (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));
 	}
 
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] staging: r8188eu: clean up comment for phy_calculate_bit_shift()
  2022-08-06  6:09 [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift() Michael Straube
  2022-08-06  6:09 ` [PATCH 1/3] staging: r8188eu: use ffs() in phy_CalculateBitShift() Michael Straube
  2022-08-06  6:09 ` [PATCH 2/3] staging: r8188eu: avoid camel case " Michael Straube
@ 2022-08-06  6:09 ` Michael Straube
  2022-08-06 18:18 ` [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift() Philipp Hortmann
  3 siblings, 0 replies; 5+ messages in thread
From: Michael Straube @ 2022-08-06  6:09 UTC (permalink / raw)
  To: gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel, Michael Straube

Clean up the comment for function phy_calculate_bit_shift().

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

diff --git a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
index e9e24efabd76..a435ec65d4b1 100644
--- a/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
+++ b/drivers/staging/r8188eu/hal/rtl8188e_phycfg.c
@@ -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);
-- 
2.37.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift()
  2022-08-06  6:09 [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift() Michael Straube
                   ` (2 preceding siblings ...)
  2022-08-06  6:09 ` [PATCH 3/3] staging: r8188eu: clean up comment for phy_calculate_bit_shift() Michael Straube
@ 2022-08-06 18:18 ` Philipp Hortmann
  3 siblings, 0 replies; 5+ messages in thread
From: Philipp Hortmann @ 2022-08-06 18:18 UTC (permalink / raw)
  To: Michael Straube, gregkh; +Cc: Larry.Finger, phil, linux-staging, linux-kernel

On 8/6/22 08:09, Michael Straube wrote:
> 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(-)
> 

Tested-by: Philipp Hortmann <philipp.g.hortmann@gmail.com> # Edimax N150

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2022-08-06 18:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-08-06  6:09 [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift() Michael Straube
2022-08-06  6:09 ` [PATCH 1/3] staging: r8188eu: use ffs() in phy_CalculateBitShift() Michael Straube
2022-08-06  6:09 ` [PATCH 2/3] staging: r8188eu: avoid camel case " Michael Straube
2022-08-06  6:09 ` [PATCH 3/3] staging: r8188eu: clean up comment for phy_calculate_bit_shift() Michael Straube
2022-08-06 18:18 ` [PATCH 0/3] staging: r8188eu: clean up phy_CalculateBitShift() Philipp Hortmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).