Skip to content

Commit

Permalink
rtlwifi: Use ffs in <foo>_phy_calculate_bit_shift
Browse files Browse the repository at this point in the history
Remove the loop and use the generic ffs instead.

Signed-off-by: Joe Perches <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
JoePerches authored and Kalle Valo committed Sep 22, 2020
1 parent 7f1e215 commit 6c1d619
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 56 deletions.
18 changes: 6 additions & 12 deletions drivers/net/wireless/realtek/rtlwifi/rtl8188ee/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,12 @@ static u32 _rtl88e_phy_rf_serial_read(struct ieee80211_hw *hw,
static void _rtl88e_phy_rf_serial_write(struct ieee80211_hw *hw,
enum radio_path rfpath, u32 offset,
u32 data);
static u32 _rtl88e_phy_calculate_bit_shift(u32 bitmask);
static u32 _rtl88e_phy_calculate_bit_shift(u32 bitmask)
{
u32 i = ffs(bitmask);

return i ? i - 1 : 32;
}
static bool _rtl88e_phy_bb8188e_config_parafile(struct ieee80211_hw *hw);
static bool _rtl88e_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);
static bool phy_config_bb_with_headerfile(struct ieee80211_hw *hw,
Expand Down Expand Up @@ -208,17 +213,6 @@ static void _rtl88e_phy_rf_serial_write(struct ieee80211_hw *hw,
rfpath, pphyreg->rf3wire_offset, data_and_addr);
}

static u32 _rtl88e_phy_calculate_bit_shift(u32 bitmask)
{
u32 i;

for (i = 0; i <= 31; i++) {
if (((bitmask >> i) & 0x1) == 1)
break;
}
return i;
}

bool rtl88e_phy_mac_config(struct ieee80211_hw *hw)
{
struct rtl_priv *rtlpriv = rtl_priv(hw);
Expand Down
8 changes: 2 additions & 6 deletions drivers/net/wireless/realtek/rtlwifi/rtl8192c/phy_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,9 @@ EXPORT_SYMBOL(_rtl92c_phy_rf_serial_write);

u32 _rtl92c_phy_calculate_bit_shift(u32 bitmask)
{
u32 i;
u32 i = ffs(bitmask);

for (i = 0; i <= 31; i++) {
if (((bitmask >> i) & 0x1) == 1)
break;
}
return i;
return i ? i - 1 : 32;
}
EXPORT_SYMBOL(_rtl92c_phy_calculate_bit_shift);

Expand Down
9 changes: 2 additions & 7 deletions drivers/net/wireless/realtek/rtlwifi/rtl8192de/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,14 +162,9 @@ static u32 targetchnl_2g[TARGET_CHNL_NUM_2G] = {

static u32 _rtl92d_phy_calculate_bit_shift(u32 bitmask)
{
u32 i;

for (i = 0; i <= 31; i++) {
if (((bitmask >> i) & 0x1) == 1)
break;
}
u32 i = ffs(bitmask);

return i;
return i ? i - 1 : 32;
}

u32 rtl92d_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
Expand Down
8 changes: 2 additions & 6 deletions drivers/net/wireless/realtek/rtlwifi/rtl8192ee/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -203,13 +203,9 @@ static void _rtl92ee_phy_rf_serial_write(struct ieee80211_hw *hw,

static u32 _rtl92ee_phy_calculate_bit_shift(u32 bitmask)
{
u32 i;
u32 i = ffs(bitmask);

for (i = 0; i <= 31; i++) {
if (((bitmask >> i) & 0x1) == 1)
break;
}
return i;
return i ? i - 1 : 32;
}

bool rtl92ee_phy_mac_config(struct ieee80211_hw *hw)
Expand Down
9 changes: 2 additions & 7 deletions drivers/net/wireless/realtek/rtlwifi/rtl8192se/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,9 @@

static u32 _rtl92s_phy_calculate_bit_shift(u32 bitmask)
{
u32 i;

for (i = 0; i <= 31; i++) {
if (((bitmask >> i) & 0x1) == 1)
break;
}
u32 i = ffs(bitmask);

return i;
return i ? i - 1 : 32;
}

u32 rtl92s_phy_query_bb_reg(struct ieee80211_hw *hw, u32 regaddr, u32 bitmask)
Expand Down
8 changes: 2 additions & 6 deletions drivers/net/wireless/realtek/rtlwifi/rtl8723com/phy_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,9 @@ EXPORT_SYMBOL_GPL(rtl8723_phy_set_bb_reg);

u32 rtl8723_phy_calculate_bit_shift(u32 bitmask)
{
u32 i;
u32 i = ffs(bitmask);

for (i = 0; i <= 31; i++) {
if (((bitmask >> i) & 0x1) == 1)
break;
}
return i;
return i ? i - 1 : 32;
}
EXPORT_SYMBOL_GPL(rtl8723_phy_calculate_bit_shift);

Expand Down
18 changes: 6 additions & 12 deletions drivers/net/wireless/realtek/rtlwifi/rtl8821ae/phy.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,12 @@ static u32 _rtl8821ae_phy_rf_serial_read(struct ieee80211_hw *hw,
static void _rtl8821ae_phy_rf_serial_write(struct ieee80211_hw *hw,
enum radio_path rfpath, u32 offset,
u32 data);
static u32 _rtl8821ae_phy_calculate_bit_shift(u32 bitmask);
static u32 _rtl8821ae_phy_calculate_bit_shift(u32 bitmask)
{
u32 i = ffs(bitmask);

return i ? i - 1 : 32;
}
static bool _rtl8821ae_phy_bb8821a_config_parafile(struct ieee80211_hw *hw);
/*static bool _rtl8812ae_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);*/
static bool _rtl8821ae_phy_config_mac_with_headerfile(struct ieee80211_hw *hw);
Expand Down Expand Up @@ -272,17 +277,6 @@ static void _rtl8821ae_phy_rf_serial_write(struct ieee80211_hw *hw,
rfpath, pphyreg->rf3wire_offset, data_and_addr);
}

static u32 _rtl8821ae_phy_calculate_bit_shift(u32 bitmask)
{
u32 i;

for (i = 0; i <= 31; i++) {
if (((bitmask >> i) & 0x1) == 1)
break;
}
return i;
}

bool rtl8821ae_phy_mac_config(struct ieee80211_hw *hw)
{
bool rtstatus = 0;
Expand Down

0 comments on commit 6c1d619

Please sign in to comment.