Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp272611rdb; Thu, 21 Dec 2023 08:44:41 -0800 (PST) X-Google-Smtp-Source: AGHT+IGE56sk01qcWFKRxpmyZ1ktO2ELc1q10HVrSpiitTUCOf7le7OaFbAhAywdXbBFHsmTUEFw X-Received: by 2002:a17:907:3a10:b0:a1d:ec18:6ad7 with SMTP id fb16-20020a1709073a1000b00a1dec186ad7mr38781ejc.53.1703177081030; Thu, 21 Dec 2023 08:44:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703177081; cv=none; d=google.com; s=arc-20160816; b=jdCpVnl4IuCirstNPocdkBNhdlS9THpLPv7Yjr/BCPdekyE4oAIp/WLXTgD/yCtUKz wYCBROz+OYrE22uuVqp5F6iFKAWadZxZ+N3kXbxW0axh+vyYP2iYURDjuboTyTiGrZKI mOA+Aao7alNL/uE1Fv+6yLpJCLyr9q5A51b+cH43QDvIltgEaIxyeGBVzGx3g3xUIjOx vzGSiqBXhmzjd3jxwLWj0099GyDiU0CG28rycn4SC/TPLkX8ysXKYo8McE0zlHhUm+9s OuzsKr4SH1SYYig5NzwnlcIafFPicnC8Ks9aW7P/vYWkLT5hL4bv9gQMhxBraWrWhWqB jJ6w== 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:references:in-reply-to:message-id :date:subject:cc:to:dkim-signature:dkim-signature:from; bh=YJF8OMXv6zsmzzE/WAkfo8NUsf2ylyf77tp+jhQnMpQ=; fh=KsoNWtazjfstHns8t6UZ1pulwZL69aEO39vRs0LPvyo=; b=F/381gdzY4jx72G/2cqy22gi/TRxDo/EB8VTfq1MIrHH9nxs8IV1H5fBSoqp1mASw0 d2KIUYArqdcePjiyUean+BNc2tnI9IkYC+j6VXgFtkrlO1L7SU2gvF7va1SlcQwmJkGz GLOwhPwS8OUM0x3taFHYWvh1JNhZiCS1tbD2cX9lFhbVpOF7VONTSOdae6dFyXAY2tJS npS8+YQ9TV6jpJmzRlh9SMKzNV23nAlwouDtA8u59PmAXc3yW9xU7Wf2AnhbP9b2WhF+ mpp5HqtoDPbJlB4aeWvjV26Z93LS7/fx4xrvFQk1/FEkkBNXVX1V6lgJRQ8L7Fbw1qP0 eq/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OMSJh7ei; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0kO597al; spf=pass (google.com: domain of linux-wireless+bounces-1155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1155-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id ew20-20020a170907951400b00a26b023ba62si135762ejc.152.2023.12.21.08.44.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 08:44:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-1155-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; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OMSJh7ei; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=0kO597al; spf=pass (google.com: domain of linux-wireless+bounces-1155-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-wireless+bounces-1155-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de 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 C451F1F23938 for ; Thu, 21 Dec 2023 16:44:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id CE4AB55E79; Thu, 21 Dec 2023 16:44:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="OMSJh7ei"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="0kO597al" X-Original-To: linux-wireless@vger.kernel.org Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 75BD258207 for ; Thu, 21 Dec 2023 16:44:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de From: Martin Kaistra DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1703177043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YJF8OMXv6zsmzzE/WAkfo8NUsf2ylyf77tp+jhQnMpQ=; b=OMSJh7ei6dgx5uN40Dahi7Wp8ygkvzEef1cxp1rWc+GSrc5kMWpO/T4He4jfZEqB78jAm9 DG/zXp9IXDF4zKN4+wspYWB35UzQU8sLnSd0O28V95AADcVfStMi0cqeJkKF7lzEGfmfSc phC0Thpzm7RbCy/lbP+yM62J2L5euLB87YhyIyRHDhpveWxkYSqkEpybb65d+RkpxmUmiO uWgWfqQu1j/wjqTxZGwZEZHfzPNNW6s4V3qMI4P/7UHTK5h1uJVGsiKTwoH7lJhJ3OBG4+ T6gc1HEsemotwWH/x+0q74NnhFYafEMOnTyY3mkAIG5jqPo/Bi0L9mjKIqPLBg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1703177043; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=YJF8OMXv6zsmzzE/WAkfo8NUsf2ylyf77tp+jhQnMpQ=; b=0kO597al0KUdFXzcjR1UPd6pB0UpK0PUZbG+MVecIQyPDA2Mmlp48q7xgJ4WlTDEi462R4 QX7KjBR6jncJ8ADQ== To: linux-wireless@vger.kernel.org Cc: Jes Sorensen , Kalle Valo , Ping-Ke Shih , Bitterblue Smith , Sebastian Andrzej Siewior Subject: [PATCH v2 06/21] wifi: rtl8xxxu: extend wifi connected check to both interfaces Date: Thu, 21 Dec 2023 17:43:38 +0100 Message-Id: <20231221164353.603258-7-martin.kaistra@linutronix.de> In-Reply-To: <20231221164353.603258-1-martin.kaistra@linutronix.de> References: <20231221164353.603258-1-martin.kaistra@linutronix.de> 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 multiple places in the code where the current connection status of wifi is checked. The driver will support two interfaces soon and either one of them (or both) could be connected. Convert all uses of (vif && vif->cfg.assoc) to a new helper function rtl8xxxu_is_assoc() which checks both interfaces. Signed-off-by: Martin Kaistra Reviewed-by: Ping-Ke Shih --- .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 20 +++++++++---------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c index c2ea8e92cd637..fd6b6e2eba038 100644 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c @@ -6043,18 +6043,20 @@ void rtl8723bu_update_bt_link_info(struct rtl8xxxu_priv *priv, u8 bt_info) btcoex->bt_busy = false; } +static inline bool rtl8xxxu_is_assoc(struct rtl8xxxu_priv *priv) +{ + return (priv->vifs[0] && priv->vifs[0]->cfg.assoc) || + (priv->vifs[1] && priv->vifs[1]->cfg.assoc); +} + static void rtl8723bu_handle_bt_inquiry(struct rtl8xxxu_priv *priv) { - struct ieee80211_vif *vif; struct rtl8xxxu_btcoex *btcoex; - bool wifi_connected; - vif = priv->vif; btcoex = &priv->bt_coex; - wifi_connected = (vif && vif->cfg.assoc); - if (!wifi_connected) { + if (!rtl8xxxu_is_assoc(priv)) { rtl8723bu_set_ps_tdma(priv, 0x8, 0x0, 0x0, 0x0, 0x0); rtl8723bu_set_coex_with_type(priv, 0); } else if (btcoex->has_sco || btcoex->has_hid || btcoex->has_a2dp) { @@ -6072,15 +6074,11 @@ void rtl8723bu_handle_bt_inquiry(struct rtl8xxxu_priv *priv) static void rtl8723bu_handle_bt_info(struct rtl8xxxu_priv *priv) { - struct ieee80211_vif *vif; struct rtl8xxxu_btcoex *btcoex; - bool wifi_connected; - vif = priv->vif; btcoex = &priv->bt_coex; - wifi_connected = (vif && vif->cfg.assoc); - if (wifi_connected) { + if (rtl8xxxu_is_assoc(priv)) { u32 val32 = 0; u32 high_prio_tx = 0, high_prio_rx = 0; @@ -7103,7 +7101,7 @@ static void rtl8xxxu_track_cfo(struct rtl8xxxu_priv *priv) int cfo_khz_a, cfo_khz_b, cfo_average; int crystal_cap; - if (!priv->vif || !priv->vif->cfg.assoc) { + if (!rtl8xxxu_is_assoc(priv)) { /* Reset */ cfo->adjust = true; -- 2.39.2