Received: by 2002:a05:7412:8d1c:b0:fa:4c10:6cad with SMTP id bj28csp27409rdb; Tue, 16 Jan 2024 13:49:39 -0800 (PST) X-Google-Smtp-Source: AGHT+IHTEvO8a6/z2AqeTsQQm/6WSepZyEA+D/sO8uSPaK+4rFq9kIhJclLxEEJ88t4OEH+p4qGc X-Received: by 2002:a17:906:255b:b0:a2d:559a:e7bf with SMTP id j27-20020a170906255b00b00a2d559ae7bfmr1344391ejb.175.1705441779509; Tue, 16 Jan 2024 13:49:39 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705441779; cv=pass; d=google.com; s=arc-20160816; b=zYWpjsHZTjaKMHA2ZDEUGFrrcb0qHaqtjehraYG1qLb8RBSEtxvvETB9je1HYeZJZo LYEwIyXLj5Odeep/jFXH/5PpvhxnTJmXZp18BhSjL9Z2CiEPnvEG8ec/VQAXG6wkKilJ xP1RBURxtjDC0ES7sM3BO4QEmj2OMRCqU7bGDKXBVHNj3H0NO+NyJyQvb1WZ6QMHjaEe zdWFvuW5mLOQMNbavFxSQPkXOyLCYWgteFT0bFBY6fDFUNfSYLtSkgmuz5g4jWO7+ivX 1f0QArFwxBwYsp3yXjStzcFkpuWSJKWGixbPS/Xy8o3fK2edIccULOJpmEAqIYsHsB4p 1QFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4tYjH4nYVnxruhcpdE+fz/XDGajx7BeRKYkrbohEsmQ=; fh=Ac+NwqQJuwR/DDoRa0E8YA/WQ/6Hf1LcmtoQVVetZMc=; b=s/4McnQVEys0rdg5BP77nn7jIZrt17RLnM3KJzwF1WiU1w+m9hSBLUv4+nd3ygcU2d wATA0BsuXGBBXoJ03T/MwKGZvw040VdAmRTOy2lvb7S618uUyT5e4cs97OVXOzMwfs+7 yXOd3BUG/MCVAwkkAh/eW2sYbSP6aCt+XGjRNBg036VujSVSgOi8r+g5YqyxsSAVsR5C qh3yI5o/0K3RIz3v66uiSPqHj+lY3nVusEIzbH2q5SMaDU0zKwU1Vk8aCwtKBpLtqWZd 19s55TyEtVtUGsg1lpfIHkYNcmjAh4xxbSvYIrBg8C7YypjyD/Pha1PoGeq3ewGWX+l3 TZyQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="LPS8Him/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-2050-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id q12-20020a170906388c00b00a26e2482dddsi5088672ejd.1030.2024.01.16.13.49.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 13:49:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-2050-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="LPS8Him/"; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-wireless+bounces-2050-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-2050-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 4319F1F2AE6A for ; Tue, 16 Jan 2024 21:49:39 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECEA21615AA; Tue, 16 Jan 2024 20:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LPS8Him/" X-Original-To: linux-wireless@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C515E405DF; Tue, 16 Jan 2024 20:02:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705435342; cv=none; b=jO+uBLTDk70OPm9v6U+BhS1ELG7XgmVNGgoKCQXK7ZffARMmDjVo0ybPUNnUWYqvBqm91ieGV9Hc4q9rDpXbNpzth4IkLmhoXXco5E78D4WAfigZyIt4vaGTZgcbmkanENv1TagpItS76gQzUID4AT36QjuMuWKhnpSNypNSuKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705435342; c=relaxed/simple; bh=cUgIoC7sYL3zlsFCb07Nc9ZrcyGFG0MovF6+8jsZkcU=; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID: X-Mailer:In-Reply-To:References:MIME-Version:X-stable: X-Patchwork-Hint:X-stable-base:Content-Transfer-Encoding; b=K24Rc5lzV1+ZcFfBqWBg4R7mDeQ90OXKelNngU1P+xb5BPLy6QjEHcRkqAPp8p5z/5gsGUNlBdGhYyal0z5V2x9iP2M78b9O+gXGBWphuucnIPmYdZdSSSmcpbyAYnScrclHSz+fkOQIi0fgn0NkzQnktn6FBRyUmc/73GiHm5c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LPS8Him/; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D618FC43390; Tue, 16 Jan 2024 20:02:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705435342; bh=cUgIoC7sYL3zlsFCb07Nc9ZrcyGFG0MovF6+8jsZkcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LPS8Him/xdZ09wN4tHRAncsDWoqiW4RnKaLS1lF0PomdNU9+L0MyPasRWIrTkKpVE JnnL5KeyQ5HTy0nE12T8pUqpkWlILmjrzKQhUo3ZUfLQFvU1mfbX3YRSHyHdXCbb9T s7jN27WmZ2ryb17VDbZbcfD+UKi0vwKI6Lj9T7+UcuY85rwsCnImo3DmbaiK1N96cZ S5a38rrpS1BDD/I54JMAyBHEFUMvewmQZDmdQBpDwEzw0dO/AfcX3RYGLS2S/70PmY kE8FssBsXLV2RH+5x9neYKYi5/39YWPZSt7tn36gJPAfEGoNHULR74DgvYpdKcbZ6Q UTWcQnJ6Yt5IA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Su Hui , Ping-Ke Shih , Kalle Valo , Sasha Levin , linux-wireless@vger.kernel.org Subject: [PATCH AUTOSEL 5.10 39/44] wifi: rtlwifi: add calculate_bit_shift() Date: Tue, 16 Jan 2024 15:00:08 -0500 Message-ID: <20240116200044.258335-39-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240116200044.258335-1-sashal@kernel.org> References: <20240116200044.258335-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-stable-base: Linux 5.10.208 Content-Transfer-Encoding: 8bit From: Su Hui [ Upstream commit 52221dfddbbfb5b4e029bb2efe9bb7da33ec1e46 ] 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 Acked-by: Ping-Ke Shih Signed-off-by: Kalle Valo Link: https://msgid.link/20231219065739.1895666-2-suhui@nfschina.com Signed-off-by: Sasha Levin --- 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 fdccfd29fd61..a89e232d6963 100644 --- a/drivers/net/wireless/realtek/rtlwifi/wifi.h +++ b/drivers/net/wireless/realtek/rtlwifi/wifi.h @@ -3111,4 +3111,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.43.0