On 22/04/2024 06:39, Ping-Ke Shih wrote: > Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> wrote: >> A few of the shared functions need small changes for the USB driver: >> - firmware loading >> - efuse reading >> - rate mask updating >> - rf register reading >> - initial gain for scanning >> >> Also, add a few macros to wifi.h and initialise rtlhal.interfaceindex >> for USB devices. >> >> Signed-off-by: Bitterblue Smith <rtl8821cerfe2@xxxxxxxxx> > > [...] > >> @@ -965,12 +983,20 @@ static void rtl92de_update_hal_rate_mask(struct ieee80211_hw *hw, >> break; >> } >> >> - value[0] = (ratr_bitmap & 0x0fffffff) | (ratr_index << 28); >> - value[1] = macid | (shortgi ? 0x20 : 0x00) | 0x80; >> + le32p_replace_bits(&rate_mask.rate_mask_and_raid, ratr_bitmap, RATE_MASK_MASK); >> + le32p_replace_bits(&rate_mask.rate_mask_and_raid, ratr_index, RAID_MASK); >> + u8p_replace_bits(&rate_mask.macid_and_short_gi, macid, MACID_MASK); >> + u8p_replace_bits(&rate_mask.macid_and_short_gi, shortgi, SHORT_GI_MASK); >> + u8p_replace_bits(&rate_mask.macid_and_short_gi, 1, BIT(7)); >> + >> rtl_dbg(rtlpriv, COMP_RATR, DBG_DMESG, >> - "ratr_bitmap :%x value0:%x value1:%x\n", >> - ratr_bitmap, value[0], value[1]); >> - rtl92d_fill_h2c_cmd(hw, H2C_RA_MASK, 5, (u8 *)value); >> + "Rate_index:%x, ratr_val:%x, %5phC\n", >> + ratr_index, ratr_bitmap, &rate_mask); >> + memcpy(rtlpriv->rate_mask, &rate_mask, sizeof(rtlpriv->rate_mask)); >> + /* rtl92d_fill_h2c_cmd() does USB I/O and will result in a >> + * "scheduled while atomic" if called directly >> + */ >> + schedule_work(&rtlpriv->works.fill_h2c_cmd); > > This function will be used by both PCI and USB, right? But, > only USB initialize/cancel rtlpriv->works.fill_h2c_cmd. > You're right, I didn't notice that. I will fix it the easy way: call rtl92d_fill_h2c_cmd() for PCI and schedule_work() for USB.