RE: [PATCH wireless-next 01/11] wifi: rtlwifi: add calculate_bit_shift()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Su Hui <suhui@xxxxxxxxxxxx>
> Sent: Tuesday, December 19, 2023 2:57 PM
> To: Ping-Ke Shih <pkshih@xxxxxxxxxxx>; kvalo@xxxxxxxxxx
> Cc: Su Hui <suhui@xxxxxxxxxxxx>; linux-wireless@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx;
> kernel-janitors@xxxxxxxxxxxxxxx
> 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@xxxxxxxxxxxx>

Acked-by: Ping-Ke Shih <pkshih@xxxxxxxxxxx>

> ---
>  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






[Index of Archives]     [Kernel Development]     [Kernel Announce]     [Kernel Newbies]     [Linux Networking Development]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Device Mapper]

  Powered by Linux