All of lore.kernel.org
 help / color / mirror / Atom feed
From: Su Hui <suhui@nfschina.com>
To: pkshih@realtek.com, kvalo@kernel.org
Cc: Su Hui <suhui@nfschina.com>,
	linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel-janitors@vger.kernel.org
Subject: [PATCH wireless-next 01/11] wifi: rtlwifi: add calculate_bit_shift()
Date: Tue, 19 Dec 2023 14:57:29 +0800	[thread overview]
Message-ID: <20231219065739.1895666-2-suhui@nfschina.com> (raw)
In-Reply-To: <20231219065739.1895666-1-suhui@nfschina.com>

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@nfschina.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
-- 
2.30.2


  reply	other threads:[~2023-12-19  6:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-19  6:57 [PATCH wireless-next 00/11] using calculate_bit_shift() to fix undefined bitwise shift behavior Su Hui
2023-12-19  6:57 ` Su Hui [this message]
2023-12-20  6:47   ` [PATCH wireless-next 01/11] wifi: rtlwifi: add calculate_bit_shift() Ping-Ke Shih
2023-12-21 14:40   ` Kalle Valo
2023-12-19  6:57 ` [PATCH wireless-next 02/11] wifi: rtlwifi: rtl8821ae: phy: using calculate_bit_shift() Su Hui
2023-12-19  6:57 ` [PATCH wireless-next 03/11] wifi: rtlwifi: rtl8188ee: " Su Hui
2023-12-19  6:57 ` [PATCH wireless-next 04/11] wifi: rtlwifi: rtl8192c: " Su Hui
2023-12-19  6:57 ` [PATCH wireless-next 05/11] wifi: rtlwifi: rtl8192cu: " Su Hui
2023-12-19  6:57 ` [PATCH wireless-next 06/11] wifi: rtlwifi: rtl8192ce: " Su Hui
2023-12-19  6:57 ` [PATCH wireless-next 07/11] wifi: rtlwifi: rtl8192de: " Su Hui
2023-12-19  6:57 ` [PATCH wireless-next 08/11] wifi: rtlwifi: rtl8192ee: " Su Hui
2023-12-19  6:57 ` [PATCH wireless-next 09/11] wifi: rtlwifi: rtl8192se: " Su Hui
2023-12-19  6:57 ` [PATCH wireless-next 10/11] wifi: rtlwifi: rtl8723_common: " Su Hui
2023-12-19  6:57 ` [PATCH wireless-next 11/11] wifi: rtlwifi: rtl8723{be,ae}: " Su Hui

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231219065739.1895666-2-suhui@nfschina.com \
    --to=suhui@nfschina.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=pkshih@realtek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.