Skip to contentSkip to conversation

staging: r8188eu: use ARRAY_SIZE() macro and fix camelcase issues

PATCH In review Vihas Mak 2 participants 3 messages Nov 29, 2021 – Nov 30, 2021 Staging

lore
Share & tools
lore

Vihas Mak

author
#0 lore raw

PATCH 1/1 staging: r8188eu: use ARRAY_SIZE() macro and fix camelcase issues

Fix camelcase warnings from checkpatch.pl and use ARRAY_SIZE() to make the code cleaner and avoid following cocci warnings:

	drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c:142:51-52: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:174:52-53: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:450:52-53: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:655:49-50: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c:136:50-51: WARNING: Use ARRAY_SIZE
---
 .../staging/r8188eu/hal/HalHWImg8188E_BB.c    |  6 ++---
 .../staging/r8188eu/hal/HalHWImg8188E_MAC.c   |  2 +-
 .../staging/r8188eu/hal/HalHWImg8188E_RF.c    | 24 +++++++++----------
 3 files changed, 16 insertions(+), 16 deletions(-)
drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +3 -3
index f6e4243e0..ce46b3651 100644
@@ -171,7 +171,7 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm)
 {
 	u32     hex         = 0;
 	u32     i           = 0;
-	u32     arraylen    = sizeof(array_agc_tab_1t_8188e) / sizeof(u32);
+	u32     arraylen    = ARRAY_SIZE(array_agc_tab_1t_8188e);
 	u32    *array       = array_agc_tab_1t_8188e;
 	bool		biol = false;
 	struct adapter *adapter =  dm_odm->Adapter;
@@ -447,7 +447,7 @@ enum HAL_STATUS ODM_ReadAndConfig_PHY_REG_1T_8188E(struct odm_dm_struct *dm_odm)
 {
 	u32     hex         = 0;
 	u32     i           = 0;
-	u32     arraylen    = sizeof(array_phy_reg_1t_8188e) / sizeof(u32);
+	u32     arraylen    = ARRAY_SIZE(array_phy_reg_1t_8188e);
 	u32    *array       = array_phy_reg_1t_8188e;
 	bool	biol = false;
 	struct adapter *adapter =  dm_odm->Adapter;
@@ -652,7 +652,7 @@ void ODM_ReadAndConfig_PHY_REG_PG_8188E(struct odm_dm_struct *dm_odm)
 {
 	u32  hex;
 	u32  i           = 0;
-	u32  arraylen    = sizeof(array_phy_reg_pg_8188e) / sizeof(u32);
+	u32  arraylen    = ARRAY_SIZE(array_phy_reg_pg_8188e);
 	u32 *array       = array_phy_reg_pg_8188e;
 
 	hex = ODM_ITRF_USB << 8;
drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c +1 -1
index b4c55863d..89061e1a3 100644
@@ -133,7 +133,7 @@ enum HAL_STATUS ODM_ReadAndConfig_MAC_REG_8188E(struct odm_dm_struct *dm_odm)
 
 	u32     hex         = 0;
 	u32     i;
-	u32     array_len    = sizeof(array_MAC_REG_8188E) / sizeof(u32);
+	u32     array_len    = ARRAY_SIZE(array_MAC_REG_8188E);
 	u32    *array       = array_MAC_REG_8188E;
 	bool	biol = false;
 
drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c +12 -12
index 5e0a96200..f708d9d90 100644
@@ -29,7 +29,7 @@ static bool CheckCondition(const u32  Condition, const u32  Hex)
 *                           RadioA_1T.TXT
 ******************************************************************************/
 
-static u32 Array_RadioA_1T_8188E[] = {
+static u32 array_RadioA_1T_8188E[] = {
 		0x000, 0x00030000,
 		0x008, 0x00084000,
 		0x018, 0x00000407,
@@ -134,13 +134,13 @@ static u32 Array_RadioA_1T_8188E[] = {
 enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm)
 {
 	#define READ_NEXT_PAIR(v1, v2, i) do	\
-		 { i += 2; v1 = Array[i];	\
-		 v2 = Array[i + 1]; } while (0)
+		 { i += 2; v1 = array[i];	\
+		 v2 = array[i + 1]; } while (0)
 
 	u32     hex         = 0;
 	u32     i           = 0;
-	u32     ArrayLen    = sizeof(Array_RadioA_1T_8188E) / sizeof(u32);
-	u32    *Array       = Array_RadioA_1T_8188E;
+	u32     array_len    = ARRAY_SIZE(array_RadioA_1T_8188E);
+	u32    *array       = array_RadioA_1T_8188E;
 	bool		biol = false;
 	struct adapter *Adapter =  pDM_Odm->Adapter;
 	struct xmit_frame *pxmit_frame = NULL;
@@ -160,9 +160,9 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm)
 		}
 	}
 
-	for (i = 0; i < ArrayLen; i += 2) {
-		u32 v1 = Array[i];
-		u32 v2 = Array[i + 1];
+	for (i = 0; i < array_len; i += 2) {
+		u32 v1 = array[i];
+		u32 v2 = array[i + 1];
 
 		/*  This (offset, data) pair meets the condition. */
 		if (v1 < 0xCDCDCDCD) {
@@ -189,19 +189,19 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm)
 			}
 			continue;
 		} else { /*  This line is the start line of branch. */
-			if (!CheckCondition(Array[i], hex)) {
+			if (!CheckCondition(array[i], hex)) {
 				/*  Discard the following (offset, data) pairs. */
 				READ_NEXT_PAIR(v1, v2, i);
 				while (v2 != 0xDEAD &&
 				       v2 != 0xCDEF &&
-				       v2 != 0xCDCD && i < ArrayLen - 2)
+				       v2 != 0xCDCD && i < array_len - 2)
 					READ_NEXT_PAIR(v1, v2, i);
 				i -= 2; /*  prevent from for-loop += 2 */
 			} else { /*  Configure matched pairs and skip to end of if-else. */
 			READ_NEXT_PAIR(v1, v2, i);
 				while (v2 != 0xDEAD &&
 				       v2 != 0xCDEF &&
-				       v2 != 0xCDCD && i < ArrayLen - 2) {
+				       v2 != 0xCDCD && i < array_len - 2) {
 					if (biol) {
 						if (rtw_IOL_cmd_boundary_handle(pxmit_frame))
 							bndy_cnt++;
@@ -226,7 +226,7 @@ enum HAL_STATUS ODM_ReadAndConfig_RadioA_1T_8188E(struct odm_dm_struct *pDM_Odm)
 					READ_NEXT_PAIR(v1, v2, i);
 				}
 
-				while (v2 != 0xDEAD && i < ArrayLen - 2)
+				while (v2 != 0xDEAD && i < array_len - 2)
 					READ_NEXT_PAIR(v1, v2, i);
 			}
 		}
Signature · 1 line
2.30.2
#1 lore raw
Quoted 21 lines · Vihas Mak

Fix camelcase warnings from checkpatch.pl and use ARRAY_SIZE() to make the code cleaner and avoid following cocci warnings:

	drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c:142:51-52: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:174:52-53: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:450:52-53: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:655:49-50: WARNING: Use ARRAY_SIZE
	drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c:136:50-51: WARNING: Use ARRAY_SIZE
---
 .../staging/r8188eu/hal/HalHWImg8188E_BB.c    |  6 ++---
 .../staging/r8188eu/hal/HalHWImg8188E_MAC.c   |  2 +-
 .../staging/r8188eu/hal/HalHWImg8188E_RF.c    | 24 +++++++++----------
 3 files changed, 16 insertions(+), 16 deletions(-)
drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +0 -0
index f6e4243e0..ce46b3651 100644

drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) · line 175

Quoted 6 lines
drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +1 -1
@@ -171,7 +171,7 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm)
 {
 	u32     hex         = 0;
 	u32     i           = 0;
-	u32     arraylen    = sizeof(array_agc_tab_1t_8188e) / sizeof(u32);
+	u32     arraylen    = ARRAY_SIZE(array_agc_tab_1t_8188e);
 	u32    *array       = array_agc_tab_1t_8188e;

Get rid of both the "arraylen" and "array" variables. They only obscure what the code is doing. You may need to do additional clean up to make it work without making the lines too long...

Same for the rest.

If that is too complicated then it's fine too, just leave it as-is for now. I know that sometimes people just want to silence the checkpatch warnings but I prefer to keep the warning as a marker for bad code so let's leave it until someone can fix this in the correct way.

regards,
dan carpenter

author
#2 lore raw
Quoted 3 lines
Quoted 3 lines

Get rid of both the "arraylen" and "array" variables. They only obscure what the code is doing. You may need to do additional clean up to make it work without making the lines too long...

Alright.

Quoted 36 lines · Dan Carpenter
Quoted 21 lines · Vihas Mak

Fix camelcase warnings from checkpatch.pl and use ARRAY_SIZE() to make the code cleaner and avoid following cocci warnings:

      drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c:142:51-52: WARNING: Use ARRAY_SIZE
      drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:174:52-53: WARNING: Use ARRAY_SIZE
      drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:450:52-53: WARNING: Use ARRAY_SIZE
      drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c:655:49-50: WARNING: Use ARRAY_SIZE
      drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c:136:50-51: WARNING: Use ARRAY_SIZE
---
 .../staging/r8188eu/hal/HalHWImg8188E_BB.c    |  6 ++---
 .../staging/r8188eu/hal/HalHWImg8188E_MAC.c   |  2 +-
 .../staging/r8188eu/hal/HalHWImg8188E_RF.c    | 24 +++++++++----------
 3 files changed, 16 insertions(+), 16 deletions(-)
drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +0 -0
index f6e4243e0..ce46b3651 100644

drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm) · line 175

Quoted 6 lines
drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c +1 -1
@@ -171,7 +171,7 @@ enum HAL_STATUS ODM_ReadAndConfig_AGC_TAB_1T_8188E(struct odm_dm_struct *dm_odm)
 {
      u32     hex         = 0;
      u32     i           = 0;
-     u32     arraylen    = sizeof(array_agc_tab_1t_8188e) / sizeof(u32);
+     u32     arraylen    = ARRAY_SIZE(array_agc_tab_1t_8188e);
      u32    *array       = array_agc_tab_1t_8188e;

Get rid of both the "arraylen" and "array" variables. They only obscure what the code is doing. You may need to do additional clean up to make it work without making the lines too long...

Same for the rest.

Quoted 8 lines

If that is too complicated then it's fine too, just leave it as-is for now. I know that sometimes people just want to silence the checkpatch warnings but I prefer to keep the warning as a marker for bad code so let's leave it until someone can fix this in the correct way.

regards,
dan carpenter

--
Thanks,
Vihas