[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a8f4058de59540eda8ab7acd08ad0cb9@realtek.com>
Date: Wed, 20 Dec 2023 06:47:51 +0000
From: Ping-Ke Shih <pkshih@...ltek.com>
To: Su Hui <suhui@...china.com>, "kvalo@...nel.org" <kvalo@...nel.org>
CC: "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"kernel-janitors@...r.kernel.org" <kernel-janitors@...r.kernel.org>
Subject: RE: [PATCH wireless-next 01/11] wifi: rtlwifi: add calculate_bit_shift()
> -----Original Message-----
> From: Su Hui <suhui@...china.com>
> Sent: Tuesday, December 19, 2023 2:57 PM
> To: Ping-Ke Shih <pkshih@...ltek.com>; kvalo@...nel.org
> Cc: Su Hui <suhui@...china.com>; linux-wireless@...r.kernel.org; linux-kernel@...r.kernel.org;
> kernel-janitors@...r.kernel.org
> Subject: [PATCH wireless-next 01/11] 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 <suhui@...china.com>
Acked-by: Ping-Ke Shih <pkshih@...ltek.com>
> ---
> drivers/net/wireless/realtek/rtlwifi/wifi.h | 7 +++++++
> 1 file changed, 7 insertions(+)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/wifi.h b/drivers/net/wireless/realtek/rtlwifi/wifi.h
> index 31a481f43a07..5d842cc394aa 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h
> +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h
> @@ -3069,4 +3069,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
Basically, this patchset is to change from below example to above one.
static u32 _rtl92d_phy_calculate_bit_shift(u32 bitmask)
{
u32 i = ffs(bitmask);
return i ? i - 1 : 32;
}
And, bitmask is expected not 0, so all are fine to me.
(I don't reply all patches one-by-one to bother people)
Ping-Ke
Powered by blists - more mailing lists