70879f861ffea040ddf5491a18272d023fae13f9
[openwrt/staging/ansuel.git] /
1 From 9aa776209ca31695bead52674ad943848ccc97d5 Mon Sep 17 00:00:00 2001
2 From: Martin Kaistra <martin.kaistra@linutronix.de>
3 Date: Fri, 22 Dec 2023 11:14:27 +0100
4 Subject: [PATCH 06/21] wifi: rtl8xxxu: extend wifi connected check to both
5 interfaces
6
7 There are multiple places in the code where the current connection
8 status of wifi is checked. The driver will support two interfaces soon
9 and either one of them (or both) could be connected.
10
11 Convert all uses of (vif && vif->cfg.assoc) to a new helper
12 function rtl8xxxu_is_assoc() which checks both interfaces.
13
14 Signed-off-by: Martin Kaistra <martin.kaistra@linutronix.de>
15 Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
16 Signed-off-by: Kalle Valo <kvalo@kernel.org>
17 Link: https://msgid.link/20231222101442.626837-7-martin.kaistra@linutronix.de
18 ---
19 .../wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 20 +++++++++----------
20 1 file changed, 9 insertions(+), 11 deletions(-)
21
22 --- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
23 +++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
24 @@ -6043,18 +6043,20 @@ void rtl8723bu_update_bt_link_info(struc
25 btcoex->bt_busy = false;
26 }
27
28 +static inline bool rtl8xxxu_is_assoc(struct rtl8xxxu_priv *priv)
29 +{
30 + return (priv->vifs[0] && priv->vifs[0]->cfg.assoc) ||
31 + (priv->vifs[1] && priv->vifs[1]->cfg.assoc);
32 +}
33 +
34 static
35 void rtl8723bu_handle_bt_inquiry(struct rtl8xxxu_priv *priv)
36 {
37 - struct ieee80211_vif *vif;
38 struct rtl8xxxu_btcoex *btcoex;
39 - bool wifi_connected;
40
41 - vif = priv->vif;
42 btcoex = &priv->bt_coex;
43 - wifi_connected = (vif && vif->cfg.assoc);
44
45 - if (!wifi_connected) {
46 + if (!rtl8xxxu_is_assoc(priv)) {
47 rtl8723bu_set_ps_tdma(priv, 0x8, 0x0, 0x0, 0x0, 0x0);
48 rtl8723bu_set_coex_with_type(priv, 0);
49 } else if (btcoex->has_sco || btcoex->has_hid || btcoex->has_a2dp) {
50 @@ -6072,15 +6074,11 @@ void rtl8723bu_handle_bt_inquiry(struct
51 static
52 void rtl8723bu_handle_bt_info(struct rtl8xxxu_priv *priv)
53 {
54 - struct ieee80211_vif *vif;
55 struct rtl8xxxu_btcoex *btcoex;
56 - bool wifi_connected;
57
58 - vif = priv->vif;
59 btcoex = &priv->bt_coex;
60 - wifi_connected = (vif && vif->cfg.assoc);
61
62 - if (wifi_connected) {
63 + if (rtl8xxxu_is_assoc(priv)) {
64 u32 val32 = 0;
65 u32 high_prio_tx = 0, high_prio_rx = 0;
66
67 @@ -7103,7 +7101,7 @@ static void rtl8xxxu_track_cfo(struct rt
68 int cfo_khz_a, cfo_khz_b, cfo_average;
69 int crystal_cap;
70
71 - if (!priv->vif || !priv->vif->cfg.assoc) {
72 + if (!rtl8xxxu_is_assoc(priv)) {
73 /* Reset */
74 cfo->adjust = true;
75