Skip to contentSkip to conversation

staging: rtl8723bs: replace magic numbers with named constants

PATCH In review Akhmad 2 participants 3 messages Jul 25 – Jul 28 1 message not in the archive Staging

lore
Share & tools
lore

Akhmad

author
#0 lore raw

PATCH 1/1 staging: rtl8723bs: replace magic numbers with named constants

Replace magic numbers 0x6404 and 0x660F in rtl8723b_InitBeaconVariables() with named constants TBTT_PROHIBIT_INIT_VAL and BCNTCFG_INIT_VAL.

This improves code readability and addresses a TODO comment requesting the removal of magic numbers from this driver.

---
 drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c +6 -4
@@ -11,6 +11,9 @@
 #include <rtl8723b_hal.h>
 #include "hal_com_h2c.h"
 
+#define TBTT_PROHIBIT_INIT_VAL 0x6404
+#define BCNTCFG_INIT_VAL       0x660F
+
 static void _FWDownloadEnable(struct adapter *padapter, bool enable)
 {
 	u8 tmp, count = 0;
@@ -878,17 +881,16 @@
 
 	rtw_write16(padapter, REG_BCN_CTRL, val16);
 
-	/*  TODO: Remove these magic number */
-	rtw_write16(padapter, REG_TBTT_PROHIBIT, 0x6404);/*  ms */
+	rtw_write16(padapter, REG_TBTT_PROHIBIT, TBTT_PROHIBIT_INIT_VAL); /* ms */
 	/*  Firmware will control REG_DRVERLYINT when power saving is enable, */
 	/*  so don't set this register on STA mode. */
 	if (check_fwstate(&padapter->mlmepriv, WIFI_STATION_STATE) == false)
-		rtw_write8(padapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME_8723B); /*  5ms */
+		rtw_write8(padapter, REG_DRVERLYINT, DRIVER_EARLY_INT_TIME_8723B); /* 5ms */
 	rtw_write8(padapter, REG_BCNDMATIM, BCN_DMA_ATIME_INT_TIME_8723B); /*  2ms */
 
 	/*  Suggested by designer timchen. Change beacon AIFS to the largest number */
 	/*  because test chip does not contension before sending beacon. by tynli. 2009.11.03 */
-	rtw_write16(padapter, REG_BCNTCFG, 0x660F);
+	rtw_write16(padapter, REG_BCNTCFG, BCNTCFG_INIT_VAL);
 
 	pHalData->RegBcnCtrlVal = rtw_read8(padapter, REG_BCN_CTRL);
 	pHalData->RegTxPause = rtw_read8(padapter, REG_TXPAUSE);
Signature · 1 line
2.39.0
maintainer
#1 lore raw
Quoted 2 lines · Akhmad

Replace magic numbers 0x6404 and 0x660F in rtl8723b_InitBeaconVariables() with named constants TBTT_PROHIBIT_INIT_VAL and BCNTCFG_INIT_VAL.

Where did these magic constant names come from? Please always document that.

Quoted 4 lines

This improves code readability and addresses a TODO comment requesting the removal of magic numbers from this driver.

Your full name please.

thanks,

greg k-h

A message that is not in the archive (sent off-list or not yet received): CACCSLCopDTUV2G9JG8yCuRnUYaOvCeNY-SHEC+xzv3kOJ3S2eg@mail.gmail.com

maintainer
#3 lore raw
Quoted 1 line · Ахмад Зубайругаджиев

Hi Greg,

For some reason you top-posted, and sent html email which is rejected by the lists :(

Please read the kernel documentation for how to configure your email client properly and resend.

thanks,

greg k-h