<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[rtl8723bs: Is REG_TBTT_PROHIBIT (0x6404) a worthwhile magic-number cleanup candidate?]]></title><description><![CDATA[<p dir="auto">Hello, I am a computer science undergraduate currently studying Linux kernel drivers.</p>
<p dir="auto">While analyzing the drivers/staging/rtl8723bs/hal/rtl8723b_hal_init.c driver, I noticed the following code:</p>
<p dir="auto">rtw_write16(padapter, REG_TBTT_PROHIBIT, 0x6404);</p>
<p dir="auto">There is also a nearby TODO comment:</p>
<p dir="auto">/* TODO: Remove these magic number */<br />
rtw_write16(padapter, REG_TBTT_PROHIBIT, 0x6404);</p>
<p dir="auto">At first I assumed this was simply a magic-number cleanup issue, but after tracing the surrounding code and register definitions, the value seems to carry more hardware-specific meaning than I initially expected.</p>
<p dir="auto">What I found<br />
Near the REG_TBTT_PROHIBIT definition, I found the following comments:</p>
<p dir="auto">// [3:0]   : TBTT prohibit setup in unit of 32us<br />
// [19:8]  : TBTT prohibit hold in unit of 32us</p>
<p dir="auto">#define REG_TBTT_PROHIBIT 0x0540</p>
<p dir="auto">Based on this, I interpreted 0x6404 as:</p>
<p dir="auto">setup field = 0x04<br />
hold field = 0x64</p>
<p dir="auto">And my understanding is that after write16():</p>
<p dir="auto">the lower byte maps to 0x540<br />
the upper byte maps to 0x541</p>
<p dir="auto">There are also nearby timing-related register writes such as:</p>
<p dir="auto">rtw_write8(padapter, REG_ATIMWND, 0x0a);      /* 10ms */<br />
rtw_write16(padapter, REG_TSFTR_SYN_OFFSET, 0x7fff);</p>
<p dir="auto">which made me think that 0x6404 is likely a hardware timing/tuning value related to beacon/TBTT handling.</p>
<p dir="auto">I also checked upstream drivers and found the exact same value still present in rtl8xxxu:</p>
<p dir="auto">rtl8xxxu_write16(priv, REG_TBTT_PROHIBIT, 0x6404);</p>
<p dir="auto">Current concern<br />
At this point, my impression is that:</p>
<p dir="auto">the value itself appears meaningful as a hardware timing parameter,<br />
it could be rewritten using symbolic bitfield macros,<br />
but since the same raw value has remained in upstream drivers for years, I am unsure whether such a cleanup would actually be considered valuable.</p>
<p dir="auto">For example, I was considering something like:</p>
<p dir="auto">#define TBTT_SETUP_TIME(_v) (((_v) &amp; 0xf) &lt;&lt; 0 )<br />
#define TBTT_HOLD_TIME(_v)  (((_v) &amp; 0xff) &lt;&lt; 8 )</p>
<p dir="auto">/* setup = 0x04, hold = 0x64 */<br />
TBTT_SETUP_TIME(0x04) | TBTT_HOLD_TIME(0x64)</p>
<p dir="auto">However, I am not sure whether this would meaningfully improve readability/maintainability, or simply make a hardware tuning constant more verbose.</p>
<p dir="auto">Questions</p>
<p dir="auto">Would maintainers generally consider this kind of change a worthwhile cleanup patch?<br />
In cases like this, where the value appears to represent a hardware timing/tuning parameter, is it usually preferred to keep the raw constant?<br />
If a staging TODO remains for many years while the same value also exists upstream, how should that usually be interpreted?</p>
<p dir="auto">I would appreciate any advice regarding both the analysis itself and whether this kind of patch is worth pursuing.</p>
]]></description><link>https://kernelmeet.com/topic/17/rtl8723bs-is-reg_tbtt_prohibit-0x6404-a-worthwhile-magic-number-cleanup-candidate</link><generator>RSS for Node</generator><lastBuildDate>Fri, 29 May 2026 17:59:15 GMT</lastBuildDate><atom:link href="https://kernelmeet.com/topic/17.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 10 May 2026 13:02:09 GMT</pubDate><ttl>60</ttl></channel></rss>