On 22/03/2024 04:14, Ping-Ke Shih wrote: [...] >> + >> +void rtl92d_get_hw_reg(struct ieee80211_hw *hw, u8 variable, u8 *val) >> +{ >> + struct rtl_priv *rtlpriv = rtl_priv(hw); >> + struct rtl_ps_ctl *ppsc = rtl_psc(rtl_priv(hw)); >> + >> + switch (variable) { >> + case HW_VAR_RF_STATE: >> + *((enum rf_pwrstate *)(val)) = ppsc->rfpwr_state; > > The casting of these set/get_hw_reg looks not good. If you have good ideas > to avoid them, welcome to adjust them afterward > My idea is more of a dream: to replace the get_hw_reg and set_hw_reg functions with many small functions, one for each HW_VAR. Most of the drivers have very similar code in these, so they could share. > >> + break; >> + case HW_VAR_FWLPS_RF_ON:{ >> + enum rf_pwrstate rfstate; >> + u32 val_rcr; >> + >> + rtlpriv->cfg->ops->get_hw_reg(hw, HW_VAR_RF_STATE, >> + (u8 *)(&rfstate)); >> + if (rfstate == ERFOFF) { >> + *((bool *)(val)) = true; >> + } else { >> + val_rcr = rtl_read_dword(rtlpriv, REG_RCR); >> + val_rcr &= 0x00070000; >> + if (val_rcr) >> + *((bool *)(val)) = false; >> + else >> + *((bool *)(val)) = true; >> + } >> + break; >> + } >> >