In drivers/net/wireless/realtek/rtlwifi/rtl8821ae/hw.c, we have this
function:
static u8 _rtl8821ae_dbi_read(struct rtl_priv *rtlpriv, u16 addr)
{
u16 read_addr = addr & 0xfffc;
u8 tmp = 0, count = 0, ret = 0;
rtl_write_word(rtlpriv, REG_DBI_ADDR, read_addr);
rtl_write_byte(rtlpriv, REG_DBI_FLAG, 0x2);
tmp = rtl_read_byte(rtlpriv, REG_DBI_FLAG);
count = 0;
while (tmp && count < 20) {
udelay(10);
tmp = rtl_read_byte(rtlpriv, REG_DBI_FLAG);
count++;
}
if (0 == tmp) {
read_addr = REG_DBI_RDATA + addr % 4;
ret = rtl_read_word(rtlpriv, read_addr);
}
return ret;
}
Near the end of the function, in this line:
ret = rtl_read_word(rtlpriv, read_addr);
rtl_read_word() returns a u16, but "ret" is declared as a u8. Is that a
problem, or is this code correct?
What's prompting this question is that I'm getting frequent disconnects
from my access point with my rtl8821ae device. I've experienced this
behavior both before and after the recent change to this function in
commit b8b8b16352cd90c6083033fd4487f04fae935c18.