Skip to contentSkip to conversation

staging: rtl8723bs: remove dead function and clean up table

PATCH In review Andrei Khomenkov 2 participants 4 messages May 22 – May 23 Staging

lore
Share & tools
lore
#0 lore raw

cover staging: rtl8723bs: remove dead function and clean up table

Remove the dead rtw_atimdone_event_callback() function since it is unused and clean up the wlanevents table.

Andrei Khomenkov (2):
staging: rtl8723bs: remove dead rtw_atimdone_event_callback()
staging: rtl8723bs: clean up wlanevents table in rtw_mlme_ext.c

 drivers/staging/rtl8723bs/core/rtw_mlme.c     |  5 --
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 54 +++++++++----------
 drivers/staging/rtl8723bs/include/rtw_mlme.h  |  1 -
 3 files changed, 26 insertions(+), 34 deletions(-)
Signature · 1 line
2.47.3
#1 lore raw

PATCH 1/2 staging: rtl8723bs: remove dead rtw_atimdone_event_callback()

Remove the dead rtw_atimdone_event_callback() function since it is unused anywhere in the driver. In the wlanevents table, replace it with rtw_dummy_event_callback() to avoid an index shift.

---
 drivers/staging/rtl8723bs/core/rtw_mlme.c     | 5 -----
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 2 +-
 drivers/staging/rtl8723bs/include/rtw_mlme.h  | 1 -
 3 files changed, 1 insertion(+), 7 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme.c +0 -5
index 4fb74729180f..6d43948ffe40 100644
@@ -624,11 +624,6 @@ static bool rtw_is_desired_network(struct adapter *adapter, struct wlan_network
 	return bselected;
 }
 
-/* TODO: Perry : For Power Management */
-void rtw_atimdone_event_callback(struct adapter	*adapter, u8 *pbuf)
-{
-}
-
 void rtw_survey_event_callback(struct adapter	*adapter, u8 *pbuf)
 {
 	u32 len;
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1 -1
index a86d6f97cf02..c56082cd5264 100644
@@ -5619,7 +5619,7 @@ static struct fwevent wlanevents[] = {
 	{0, &rtw_joinbss_event_callback},		/*10*/
 	{sizeof(struct stassoc_event), &rtw_stassoc_event_callback},
 	{sizeof(struct stadel_event), &rtw_stadel_event_callback},
-	{0, &rtw_atimdone_event_callback},
+	{0, rtw_dummy_event_callback},
 	{0, rtw_dummy_event_callback},
 	{0, NULL},	/*15*/
 	{0, NULL},
drivers/staging/rtl8723bs/include/rtw_mlme.h +0 -1
index 8cc96164e1cf..e2fd899d6579 100644
@@ -258,7 +258,6 @@ extern void rtw_surveydone_event_callback(struct adapter *adapter, u8 *pbuf);
 extern void rtw_joinbss_event_callback(struct adapter *adapter, u8 *pbuf);
 extern void rtw_stassoc_event_callback(struct adapter *adapter, u8 *pbuf);
 extern void rtw_stadel_event_callback(struct adapter *adapter, u8 *pbuf);
-extern void rtw_atimdone_event_callback(struct adapter *adapter, u8 *pbuf);
 extern void rtw_cpwm_event_callback(struct adapter *adapter, u8 *pbuf);
 extern void rtw_wmm_event_callback(struct adapter *padapter, u8 *pbuf);
 
Signature · 1 line
2.47.3
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] staging: rtl8723bs: remove dead rtw_atimdone_event_callback()

drivers/staging/rtl8723bs/core/rtw_mlme_ext.c static struct fwevent wlanevents[] = { · line 5625

Quoted 13 lines · Andrei Khomenkov
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +1 -1
index a86d6f97cf02..c56082cd5264 100644
@@ -5619,7 +5619,7 @@ static struct fwevent wlanevents[] = {
 	{0, &rtw_joinbss_event_callback},		/*10*/
 	{sizeof(struct stassoc_event), &rtw_stassoc_event_callback},
 	{sizeof(struct stadel_event), &rtw_stadel_event_callback},
-	{0, &rtw_atimdone_event_callback},
+	{0, rtw_dummy_event_callback},
 	{0, rtw_dummy_event_callback},
 	{0, NULL},	/*15*/
 	{0, NULL},

This patch is fine...

But, dummy functions are really discouraged. It's supposed to be that the caller checks for NULL and then doesn't call it. No point in having a do nothing dummy function when we could just store a NULL pointer there instead.

And most of that table is NULL pointers! I looked at the callers and it's alarming that I don't immediately see any NULL checks.

5657 /* checking if event size match the event parm size */
5658 if ((wlanevents[evt_code].parmsize != 0) &&

If the callback is NULL then parmsize is 0 so we don't care about the size... Just continue.

  5659              (wlanevents[evt_code].parmsize != evt_sz))
  5660                  goto _abort_event_;
  5661  
  5662          atomic_inc(&pevt_priv->event_seq);
  5663  
  5664          peventbuf += 2;
  5665  
  5666          if (peventbuf) {
  5667                  event_callback = wlanevents[evt_code].event_callback;

Get the call back.

  5668                  event_callback(padapter, (u8 *)peventbuf);

And crash... I guess we are relying on this table to be in sync with the wlancmds[] table in drivers/staging/rtl8723bs/core/rtw_cmd.c. That seems pretty risky to me.

5669
5670 pevt_priv->evt_done_cnt++;
5671 }

regards,
dan carpenter

#3 lore raw

PATCH 2/2 staging: rtl8723bs: clean up wlanevents table in rtw_mlme_ext.c

In reply to Andrei Khomenkov

Clean up the wlanevents table by removing redundant ampersands, adding all index comments and aligning them.

---
 drivers/staging/rtl8723bs/core/rtw_mlme_ext.c | 54 +++++++++----------
 1 file changed, 26 insertions(+), 28 deletions(-)
drivers/staging/rtl8723bs/core/rtw_mlme_ext.c +26 -28
index c56082cd5264..eaedff8ae2e2 100644
@@ -5605,34 +5605,32 @@ u8 set_tx_beacon_cmd(struct adapter *padapter)
 }
 
 static struct fwevent wlanevents[] = {
-	{0, rtw_dummy_event_callback},	/*0*/
-	{0, NULL},
-	{0, NULL},
-	{0, NULL},
-	{0, NULL},
-	{0, NULL},
-	{0, NULL},
-	{0, NULL},
-	{0, &rtw_survey_event_callback},		/*8*/
-	{sizeof(struct surveydone_event), &rtw_surveydone_event_callback},	/*9*/
-
-	{0, &rtw_joinbss_event_callback},		/*10*/
-	{sizeof(struct stassoc_event), &rtw_stassoc_event_callback},
-	{sizeof(struct stadel_event), &rtw_stadel_event_callback},
-	{0, rtw_dummy_event_callback},
-	{0, rtw_dummy_event_callback},
-	{0, NULL},	/*15*/
-	{0, NULL},
-	{0, NULL},
-	{0, NULL},
-	{0, rtw_fwdbg_event_callback},
-	{0, NULL},	 /*20*/
-	{0, NULL},
-	{0, NULL},
-	{0, &rtw_cpwm_event_callback},
-	{0, NULL},
-	{0, &rtw_wmm_event_callback},
-
+	{0, rtw_dummy_event_callback},						/*  0 */
+	{0, NULL},								/*  1 */
+	{0, NULL},								/*  2 */
+	{0, NULL},								/*  3 */
+	{0, NULL},								/*  4 */
+	{0, NULL},								/*  5 */
+	{0, NULL},								/*  6 */
+	{0, NULL},								/*  7 */
+	{0, rtw_survey_event_callback},						/*  8 */
+	{sizeof(struct surveydone_event), rtw_surveydone_event_callback},	/*  9 */
+	{0, rtw_joinbss_event_callback},					/* 10 */
+	{sizeof(struct stassoc_event), rtw_stassoc_event_callback},		/* 11 */
+	{sizeof(struct stadel_event), rtw_stadel_event_callback},		/* 12 */
+	{0, rtw_dummy_event_callback},						/* 13 */
+	{0, rtw_dummy_event_callback},						/* 14 */
+	{0, NULL},								/* 15 */
+	{0, NULL},								/* 16 */
+	{0, NULL},								/* 17 */
+	{0, NULL},								/* 18 */
+	{0, rtw_fwdbg_event_callback},						/* 19 */
+	{0, NULL},								/* 20 */
+	{0, NULL},								/* 21 */
+	{0, NULL},								/* 22 */
+	{0, rtw_cpwm_event_callback},						/* 23 */
+	{0, NULL},								/* 24 */
+	{0, rtw_wmm_event_callback},						/* 25 */
 };
 
 u8 mlme_evt_hdl(struct adapter *padapter, unsigned char *pbuf)
Signature · 1 line
2.47.3