On 17/04/2024 07:04, Ping-Ke Shih wrote: > Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> wrote: >> [...] >> +static void _rtl92de_read_adapter_info(struct ieee80211_hw *hw) >> +{ >> + struct rtl_priv *rtlpriv = rtl_priv(hw); >> + struct rtl_efuse *rtlefuse = rtl_efuse(rtl_priv(hw)); >> + struct rtl_hal *rtlhal = rtl_hal(rtl_priv(hw)); >> + int params[] = {RTL8190_EEPROM_ID, EEPROM_VID, EEPROM_DID, >> + EEPROM_SVID, EEPROM_SMID, EEPROM_MAC_ADDR_MAC0_92D, >> + EEPROM_CHANNEL_PLAN, EEPROM_VERSION, EEPROM_CUSTOMER_ID, >> + COUNTRY_CODE_WORLD_WIDE_13}; >> + int i; >> + u16 usvalue; >> + u8 *hwinfo; >> + >> + hwinfo = kzalloc(HWSET_MAX_SIZE, GFP_KERNEL); >> + if (!hwinfo) >> + return; >> + >> + if (rtl_get_hwinfo(hw, rtlpriv, HWSET_MAX_SIZE, hwinfo, params)) >> + goto exit; >> + >> + _rtl92de_efuse_update_chip_version(hw); >> + _rtl92de_read_macphymode_and_bandtype(hw, hwinfo); >> + >> + /* Read Permanent MAC address for 2nd interface */ >> + if (rtlhal->interfaceindex != 0) { >> + for (i = 0; i < 6; i += 2) { >> + usvalue = *(u16 *)&hwinfo[EEPROM_MAC_ADDR_MAC1_92D + i]; >> + *((u16 *)(&rtlefuse->dev_addr[i])) = usvalue; > > Copying u16 looks weird. I guess it would like to swap bytes (endian problem). > At least it should be '__le16' or '__be16' because hwinfo[] is from efuse. > It is weird. rtl_get_hwinfo() in efuse.c does the same thing. I don't think this code is swapping the bytes. What reason can it have to swap them anyway? Maybe it's a (questionable) optimisation, only three copies instead of six. >> + } >> + } >> + rtlpriv->cfg->ops->set_hw_reg(hw, HW_VAR_ETHER_ADDR, >> + rtlefuse->dev_addr); >> + rtl_dbg(rtlpriv, COMP_INIT, DBG_DMESG, "%pM\n", rtlefuse->dev_addr); >> + _rtl92de_read_txpower_info(hw, rtlefuse->autoload_failflag, hwinfo);