[PATCH v2] staging: rtl8723bs: replace magic number in InitBeaconParameters

Anantha Krishnan posted 1 patch 2 weeks ago
drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
[PATCH v2] staging: rtl8723bs: replace magic number in InitBeaconParameters
Posted by Anantha Krishnan 2 weeks ago
Per the bitfield comment in hal_com_reg.h, REG_TBTT_PROHIBIT packs
a "setup" time in bits 3:0 and a "hold" time in bits 19:8. The
rtw_write16() call here only writes the low 16 bits of that
register, covering the full setup field and the low byte of the
hold field.

Replace the magic number 0x6404 with two named constants
representing these fields.

No functional change.

Bit-field positions are documented in the comment above
REG_TBTT_PROHIBIT in drivers/staging/rtl8723bs/include/hal_com_reg.h.

Signed-off-by: Anantha Krishnan <ananthanr.off@gmail.com>
---
v2: Use full name in Signed-off-by and document the source of the
    bitfield values (comment above REG_TBTT_PROHIBIT in hal_com_reg.h)
    per Greg's review.
 drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
index bcaf63b2893c..699e24f52392 100644
--- a/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
+++ b/drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c
@@ -11,6 +11,13 @@
 #include <rtl8723b_hal.h>
 #include "hal_com_h2c.h"
 
+/*
+ * Bitfield layout per the comment above REG_TBTT_PROHIBIT in
+ * drivers/staging/rtl8723bs/include/hal_com_reg.h.
+ */
+#define TBTT_PROHIBIT_SETUP     0x04  /* bits 3:0: setup time, unit 32us */
+#define TBTT_PROHIBIT_HOLD_LOW  0x64  /* bits 15:8: low byte of 12-bit hold time, unit 32us */
+
 static void _FWDownloadEnable(struct adapter *padapter, bool enable)
 {
 	u8 tmp, count = 0;
@@ -861,8 +868,8 @@ void rtl8723b_InitBeaconParameters(struct adapter *padapter)
 
 	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_HOLD_LOW << 8) | TBTT_PROHIBIT_SETUP);/*  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))
-- 
2.43.0
Re: [PATCH v2] staging: rtl8723bs: replace magic number in InitBeaconParameters
Posted by Greg Kroah-Hartman 1 week, 3 days ago
On Sat, Jul 11, 2026 at 12:09:02PM +0530, Anantha Krishnan wrote:
> Per the bitfield comment in hal_com_reg.h, REG_TBTT_PROHIBIT packs
> a "setup" time in bits 3:0 and a "hold" time in bits 19:8. The
> rtw_write16() call here only writes the low 16 bits of that
> register, covering the full setup field and the low byte of the
> hold field.
> 
> Replace the magic number 0x6404 with two named constants
> representing these fields.
> 
> No functional change.
> 
> Bit-field positions are documented in the comment above
> REG_TBTT_PROHIBIT in drivers/staging/rtl8723bs/include/hal_com_reg.h.
> 
> Signed-off-by: Anantha Krishnan <ananthanr.off@gmail.com>
> ---
> v2: Use full name in Signed-off-by and document the source of the
>     bitfield values (comment above REG_TBTT_PROHIBIT in hal_com_reg.h)
>     per Greg's review.
>  drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)

This should be v3, as you already sent a v2 :(
Re: [PATCH v2] staging: rtl8723bs: replace magic number in InitBeaconParameters
Posted by Dan Carpenter 2 weeks ago
On Sat, Jul 11, 2026 at 12:09:02PM +0530, Anantha Krishnan wrote:
> Per the bitfield comment in hal_com_reg.h, REG_TBTT_PROHIBIT packs
> a "setup" time in bits 3:0 and a "hold" time in bits 19:8. The
> rtw_write16() call here only writes the low 16 bits of that
> register, covering the full setup field and the low byte of the
> hold field.
> 
> Replace the magic number 0x6404 with two named constants
> representing these fields.
> 
> No functional change.
> 
> Bit-field positions are documented in the comment above
> REG_TBTT_PROHIBIT in drivers/staging/rtl8723bs/include/hal_com_reg.h.
> 
> Signed-off-by: Anantha Krishnan <ananthanr.off@gmail.com>
> ---
> v2: Use full name in Signed-off-by and document the source of the
>     bitfield values (comment above REG_TBTT_PROHIBIT in hal_com_reg.h)
>     per Greg's review.

Please wait 24 hours between resends.  Otherwise it feels like we're
holding your hand while you write code.  It's overwhelming for
reviewers.

https://staticthinking.wordpress.com/2022/07/27/how-to-send-a-v2-patch/

regards,
dan carpenter