wifi: rtlwifi: rtl8192se: using calculate_bit_shift()
authorSu Hui <suhui@nfschina.com>
Tue, 19 Dec 2023 06:57:37 +0000 (14:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:29 +0000 (15:35 -0800)
[ Upstream commit ac32b9317063b101a8ff3d3e885f76f87a280419 ]

Using calculate_bit_shift() to replace _rtl92s_phy_calculate_bit_shift().
And fix the undefined bitwise shift behavior problem.

Fixes: d15853163bea ("rtlwifi: rtl8192se: Merge phy routines")
Signed-off-by: Su Hui <suhui@nfschina.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20231219065739.1895666-10-suhui@nfschina.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c

index 09591a0..d9ef7e1 100644 (file)
 #include "hw.h"
 #include "table.h"
 
-static u32 _rtl92s_phy_calculate_bit_shift(u32 bitmask)
-{
-       u32 i = ffs(bitmask);
-
-       return i ? i - 1 : 32;
-}
-
 u32 rtl92s_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -30,7 +23,7 @@ u32 rtl92s_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
                regaddr, bitmask);
 
        originalvalue = rtl_read_dword(rtlpriv, regaddr);
-       bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
+       bitshift = calculate_bit_shift(bitmask);
        returnvalue = (originalvalue & bitmask) >> bitshift;
 
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE, "BBR MASK=0x%x Addr[0x%x]=0x%x\n",
@@ -52,7 +45,7 @@ void rtl92s_phy_set_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask,
 
        if (bitmask != MASKDWORD) {
                originalvalue = rtl_read_dword(rtlpriv, regaddr);
-               bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
+               bitshift = calculate_bit_shift(bitmask);
                data = ((originalvalue & (~bitmask)) | (data << bitshift));
        }
 
@@ -157,7 +150,7 @@ u32 rtl92s_phy_query_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
 
        original_value = _rtl92s_phy_rf_serial_read(hw, rfpath, regaddr);
 
-       bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
+       bitshift = calculate_bit_shift(bitmask);
        readback_value = (original_value & bitmask) >> bitshift;
 
        spin_unlock(&rtlpriv->locks.rf_lock);
@@ -188,7 +181,7 @@ void rtl92s_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
        if (bitmask != RFREG_OFFSET_MASK) {
                original_value = _rtl92s_phy_rf_serial_read(hw, rfpath,
                                                            regaddr);
-               bitshift = _rtl92s_phy_calculate_bit_shift(bitmask);
+               bitshift = calculate_bit_shift(bitmask);
                data = ((original_value & (~bitmask)) | (data << bitshift));
        }