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

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

Fixes: 7274a8c22980 ("rtlwifi: rtl8192de: 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-8-suhui@nfschina.com
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c

index d18c092b6142636471271a3cb2f9031cea18794b..d835a27429f0ff1736d58d71ab08ba6d22809ca5 100644 (file)
@@ -169,13 +169,6 @@ static const u8 channel_all[59] = {
        157, 159, 161, 163, 165
 };
 
-static u32 _rtl92d_phy_calculate_bit_shift(u32 bitmask)
-{
-       u32 i = ffs(bitmask);
-
-       return i ? i - 1 : 32;
-}
-
 u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
 {
        struct rtl_priv *rtlpriv = rtl_priv(hw);
@@ -198,7 +191,7 @@ u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
        } else {
                originalvalue = rtl_read_dword(rtlpriv, regaddr);
        }
-       bitshift = _rtl92d_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",
@@ -230,7 +223,7 @@ void rtl92d_phy_set_bb_reg(struct ieee80211_hw *hw,
                                        dbi_direct);
                else
                        originalvalue = rtl_read_dword(rtlpriv, regaddr);
-               bitshift = _rtl92d_phy_calculate_bit_shift(bitmask);
+               bitshift = calculate_bit_shift(bitmask);
                data = ((originalvalue & (~bitmask)) | (data << bitshift));
        }
        if (rtlhal->during_mac1init_radioa || rtlhal->during_mac0init_radiob)
@@ -317,7 +310,7 @@ u32 rtl92d_phy_query_rf_reg(struct ieee80211_hw *hw,
                regaddr, rfpath, bitmask);
        spin_lock(&rtlpriv->locks.rf_lock);
        original_value = _rtl92d_phy_rf_serial_read(hw, rfpath, regaddr);
-       bitshift = _rtl92d_phy_calculate_bit_shift(bitmask);
+       bitshift = calculate_bit_shift(bitmask);
        readback_value = (original_value & bitmask) >> bitshift;
        spin_unlock(&rtlpriv->locks.rf_lock);
        rtl_dbg(rtlpriv, COMP_RF, DBG_TRACE,
@@ -343,7 +336,7 @@ void rtl92d_phy_set_rf_reg(struct ieee80211_hw *hw, enum radio_path rfpath,
                if (bitmask != RFREG_OFFSET_MASK) {
                        original_value = _rtl92d_phy_rf_serial_read(hw,
                                rfpath, regaddr);
-                       bitshift = _rtl92d_phy_calculate_bit_shift(bitmask);
+                       bitshift = calculate_bit_shift(bitmask);
                        data = ((original_value & (~bitmask)) |
                                (data << bitshift));
                }