All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: use ARRAY_SIZE() macro and fix camelcase issues
@ 2021-11-29 22:13 Vihas Mak
  2021-11-30  9:47 ` Dan Carpenter
  0 siblings, 1 reply; 3+ messages in thread
From: Vihas Mak @ 2021-11-29 22:13 UTC (permalink / raw)
  To: Larry.Finger, phil; +Cc: gregkh, martin, linux-staging, linux-kernel, 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

Signed-off-by: Vihas Mak <makvihas@gmail.com>
---
 .../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(-)

diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
index f6e4243e0..ce46b3651 100644
--- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
+++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
@@ -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;
diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c
index b4c55863d..89061e1a3 100644
--- a/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c
+++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_MAC.c
@@ -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;
 
diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c
index 5e0a96200..f708d9d90 100644
--- a/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c
+++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_RF.c
@@ -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);
 			}
 		}
-- 
2.30.2


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

* Re: [PATCH] staging: r8188eu: use ARRAY_SIZE() macro and fix camelcase issues
  2021-11-29 22:13 [PATCH] staging: r8188eu: use ARRAY_SIZE() macro and fix camelcase issues Vihas Mak
@ 2021-11-30  9:47 ` Dan Carpenter
  2021-11-30 11:17   ` Vihas Mak
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2021-11-30  9:47 UTC (permalink / raw)
  To: Vihas Mak; +Cc: Larry.Finger, phil, gregkh, martin, linux-staging, linux-kernel

On Tue, Nov 30, 2021 at 03:43:47AM +0530, Vihas Mak wrote:
> 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
> 
> Signed-off-by: Vihas Mak <makvihas@gmail.com>
> ---
>  .../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(-)
> 
> diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
> index f6e4243e0..ce46b3651 100644
> --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
> +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
> @@ -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


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

* Re: [PATCH] staging: r8188eu: use ARRAY_SIZE() macro and fix camelcase issues
  2021-11-30  9:47 ` Dan Carpenter
@ 2021-11-30 11:17   ` Vihas Mak
  0 siblings, 0 replies; 3+ messages in thread
From: Vihas Mak @ 2021-11-30 11:17 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Larry.Finger, Phillip Potter, Greg KH, martin, linux-staging,
	linux-kernel

>> 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.


On Tue, Nov 30, 2021 at 3:18 PM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> On Tue, Nov 30, 2021 at 03:43:47AM +0530, Vihas Mak wrote:
> > 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
> >
> > Signed-off-by: Vihas Mak <makvihas@gmail.com>
> > ---
> >  .../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(-)
> >
> > diff --git a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
> > index f6e4243e0..ce46b3651 100644
> > --- a/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
> > +++ b/drivers/staging/r8188eu/hal/HalHWImg8188E_BB.c
> > @@ -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
>


--
Thanks,
Vihas

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

end of thread, other threads:[~2021-11-30 11:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-11-29 22:13 [PATCH] staging: r8188eu: use ARRAY_SIZE() macro and fix camelcase issues Vihas Mak
2021-11-30  9:47 ` Dan Carpenter
2021-11-30 11:17   ` Vihas Mak

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.