diff options
| author | Su Hui <[email protected]> | 2023-12-19 14:57:29 +0800 |
|---|---|---|
| committer | Kalle Valo <[email protected]> | 2023-12-21 16:40:16 +0200 |
| commit | 52221dfddbbfb5b4e029bb2efe9bb7da33ec1e46 (patch) | |
| tree | 91d8311cdbea209b3a6b633ae6f1ba6cddd09279 | |
| parent | 28a197af3fcbb47195d94cd6e612d9338aac9345 (diff) | |
wifi: rtlwifi: add calculate_bit_shift()
There are many same functions like _rtl88e_phy_calculate_bit_shift(),
_rtl92c_phy_calculate_bit_shift() and so on. And these functions can
cause undefined bitwise shift behavior. Add calculate_bit_shift() to
replace them and fix undefined behavior in subsequent patches.
Signed-off-by: Su Hui <[email protected]>
Acked-by: Ping-Ke Shih <[email protected]>
Signed-off-by: Kalle Valo <[email protected]>
Link: https://msgid.link/[email protected]
| -rw-r--r-- | drivers/net/wireless/realtek/rtlwifi/wifi.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h index ac8dfda7099d..d87cd2252eac 100644 --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h @@ -3052,4 +3052,11 @@ static inline struct ieee80211_sta *rtl_find_sta(struct ieee80211_hw *hw, return ieee80211_find_sta(mac->vif, mac_addr); } +static inline u32 calculate_bit_shift(u32 bitmask) +{ + if (WARN_ON_ONCE(!bitmask)) + return 0; + + return __ffs(bitmask); +} #endif |