Received: by 2002:a05:7412:8598:b0:f9:33c2:5753 with SMTP id n24csp320872rdh; Mon, 18 Dec 2023 22:59:40 -0800 (PST) X-Google-Smtp-Source: AGHT+IFews8wHXf0c3/4QM8PobGHemxp4M9ih1k4iDz/YjcAzWhX9EcrSqLTth+5ApPnxg6VctKT X-Received: by 2002:a05:600c:4d0e:b0:40b:5e1e:cf1 with SMTP id u14-20020a05600c4d0e00b0040b5e1e0cf1mr8569574wmp.44.1702969180319; Mon, 18 Dec 2023 22:59:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702969180; cv=none; d=google.com; s=arc-20160816; b=tBAI+RSqGPhFGzAXulZ2DI2nwteUOIcjCSR/JIikY/XWrVej7IE5NuJBthk9kJFHxU jMh1nBe2EWm4GyD4Gwh2YaKMRm0HFGF1Ch3SLVO+uJYo6/DcwIpTJxykvSGxbXVqM1JR TU634/5yyGu0YtwiTIdqtkZjpHCvsFaCjWTq5r+U5yKF+ZqlyZC8MUDuep2cgmg5MHwq 0fWEo6dRapDLoX6wlv+CE+6pbOfypurq2EDEaxMl7bqlx7myffsdPQv4l9tGf4ZHaSTa Y5aav37dJvpUVAokJfRcQYMYKkoKaIpXkLG44rpbU80nIvap/sO9CKcD/UxEoydeuNhM YmLQ== ARC-Message-Signature: i=1; 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:in-reply-to:message-id:date :subject:cc:to:from; bh=TqRUwQAmOUjnACz/ArhEp7m2ZOV4ks6KndEJJ0g9xdU=; fh=oAKK2Tmfich+PEAEhU13cYP9znewSj73CMUuWFedCmY=; b=CgxPDRfi30Dv0yhSa8kRr+fdDlWopolNfgI/EmusQA1nUB/zmCW3Rr41WSiUoVFcG4 WlArMedcTelz4kfkay8OG7PhF7zhzkZ4tgvewiqZmD6LwCUq7Y0gVM6ZflQiuWJaNaVf c38NhgiPUV5Ec2PjW3zsbZ++ZhNIk5LWBVSFfmMNL3Cf6KTs0W14zLS/HTihLGFJw56W V1dt/Q3UVq6Ey3L10D1Y2lO0oHuU7JFL1tjQGgV5ZwVxM1kqy1T0fP7cDDDd+t05ZdS4 6ka5dupsQx7zcrTrzE57jo7QidCrx95ttahabuxnt8oPe4U5zMO2rPEzjo8zOlcWxKc8 WH8Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-958-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id v20-20020a170906339400b00a236de74149si629138eja.760.2023.12.18.22.59.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Dec 2023 22:59:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-wireless+bounces-958-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-958-linux.lists.archive=gmail.com@vger.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 19BFB1F24B09 for ; Tue, 19 Dec 2023 06:59:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8D83D13AE2; Tue, 19 Dec 2023 06:58:12 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from mail.nfschina.com (unknown [42.101.60.195]) by smtp.subspace.kernel.org (Postfix) with SMTP id 78E0011709; Tue, 19 Dec 2023 06:58:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=nfschina.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nfschina.com Received: from localhost.localdomain (unknown [180.167.10.98]) by mail.nfschina.com (Maildata Gateway V2.8.8) with ESMTPSA id B484B60F259C1; Tue, 19 Dec 2023 14:57:54 +0800 (CST) X-MD-Sfrom: suhui@nfschina.com X-MD-SrcIP: 180.167.10.98 From: Su Hui To: pkshih@realtek.com, kvalo@kernel.org Cc: Su Hui , 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 Message-Id: <20231219065739.1895666-2-suhui@nfschina.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20231219065739.1895666-1-suhui@nfschina.com> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 --- 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