wifi: rtlwifi: rtl8192ee: using calculate_bit_shift()
[ Upstream commit 63526897fc0d086069bcab67c3a112caaec751cb ]
Using calculate_bit_shift() to replace _rtl92ee_phy_calculate_bit_shift().
And fix the undefined bitwise shift behavior problem.
Fixes: b1a3bfc97c
("rtlwifi: rtl8192ee: Move driver from staging to the regular tree")
Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20231219065739.1895666-9-suhui@nfschina.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
4838d16666
commit
8fa54f7532
@ -16,7 +16,6 @@ static u32 _rtl92ee_phy_rf_serial_read(struct ieee80211_hw *hw,
|
|||||||
static void _rtl92ee_phy_rf_serial_write(struct ieee80211_hw *hw,
|
static void _rtl92ee_phy_rf_serial_write(struct ieee80211_hw *hw,
|
||||||
enum radio_path rfpath, u32 offset,
|
enum radio_path rfpath, u32 offset,
|
||||||
u32 data);
|
u32 data);
|
||||||
static u32 _rtl92ee_phy_calculate_bit_shift(u32 bitmask);
|
|
||||||
static bool _rtl92ee_phy_bb8192ee_config_parafile(struct ieee80211_hw *hw);
|
static bool _rtl92ee_phy_bb8192ee_config_parafile(struct ieee80211_hw *hw);
|
||||||
static bool _rtl92ee_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);
|
static bool _rtl92ee_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);
|
||||||
static bool phy_config_bb_with_hdr_file(struct ieee80211_hw *hw,
|
static bool phy_config_bb_with_hdr_file(struct ieee80211_hw *hw,
|
||||||
@ -46,7 +45,7 @@ u32 rtl92ee_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
|
|||||||
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
|
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
|
||||||
"regaddr(%#x), bitmask(%#x)\n", regaddr, bitmask);
|
"regaddr(%#x), bitmask(%#x)\n", regaddr, bitmask);
|
||||||
originalvalue = rtl_read_dword(rtlpriv, regaddr);
|
originalvalue = rtl_read_dword(rtlpriv, regaddr);
|
||||||
bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask);
|
bitshift = calculate_bit_shift(bitmask);
|
||||||
returnvalue = (originalvalue & bitmask) >> bitshift;
|
returnvalue = (originalvalue & bitmask) >> bitshift;
|
||||||
|
|
||||||
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
|
RT_TRACE(rtlpriv, COMP_RF, DBG_TRACE,
|
||||||
@ -68,7 +67,7 @@ void rtl92ee_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr,
|
|||||||
|
|
||||||
if (bitmask != MASKDWORD) {
|
if (bitmask != MASKDWORD) {
|
||||||
originalvalue = rtl_read_dword(rtlpriv, regaddr);
|
originalvalue = rtl_read_dword(rtlpriv, regaddr);
|
||||||
bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask);
|
bitshift = calculate_bit_shift(bitmask);
|
||||||
data = ((originalvalue & (~bitmask)) | (data << bitshift));
|
data = ((originalvalue & (~bitmask)) | (data << bitshift));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +92,7 @@ u32 rtl92ee_phy_query_rf_reg(struct ieee80211_hw *hw,
|
|||||||
spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags);
|
spin_lock_irqsave(&rtlpriv->locks.rf_lock, flags);
|
||||||
|
|
||||||
original_value = _rtl92ee_phy_rf_serial_read(hw , rfpath, regaddr);
|
original_value = _rtl92ee_phy_rf_serial_read(hw , rfpath, regaddr);
|
||||||
bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask);
|
bitshift = calculate_bit_shift(bitmask);
|
||||||
readback_value = (original_value & bitmask) >> bitshift;
|
readback_value = (original_value & bitmask) >> bitshift;
|
||||||
|
|
||||||
spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags);
|
spin_unlock_irqrestore(&rtlpriv->locks.rf_lock, flags);
|
||||||
@ -121,7 +120,7 @@ void rtl92ee_phy_set_rf_reg(struct ieee80211_hw *hw,
|
|||||||
|
|
||||||
if (bitmask != RFREG_OFFSET_MASK) {
|
if (bitmask != RFREG_OFFSET_MASK) {
|
||||||
original_value = _rtl92ee_phy_rf_serial_read(hw, rfpath, addr);
|
original_value = _rtl92ee_phy_rf_serial_read(hw, rfpath, addr);
|
||||||
bitshift = _rtl92ee_phy_calculate_bit_shift(bitmask);
|
bitshift = calculate_bit_shift(bitmask);
|
||||||
data = (original_value & (~bitmask)) | (data << bitshift);
|
data = (original_value & (~bitmask)) | (data << bitshift);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,13 +203,6 @@ static void _rtl92ee_phy_rf_serial_write(struct ieee80211_hw *hw,
|
|||||||
pphyreg->rf3wire_offset, data_and_addr);
|
pphyreg->rf3wire_offset, data_and_addr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 _rtl92ee_phy_calculate_bit_shift(u32 bitmask)
|
|
||||||
{
|
|
||||||
u32 i = ffs(bitmask);
|
|
||||||
|
|
||||||
return i ? i - 1 : 32;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool rtl92ee_phy_mac_config(struct ieee80211_hw *hw)
|
bool rtl92ee_phy_mac_config(struct ieee80211_hw *hw)
|
||||||
{
|
{
|
||||||
return _rtl92ee_phy_config_mac_with_headerfile(hw);
|
return _rtl92ee_phy_config_mac_with_headerfile(hw);
|
||||||
|
Loading…
Reference in New Issue
Block a user