wifi: rtl8xxxu: extend wifi connected check to both interfaces

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 <martin.kaistra@linutronix.de>
Reviewed-by: Ping-Ke Shih <pkshih@realtek.com>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20231222101442.626837-7-martin.kaistra@linutronix.de
This commit is contained in:
Martin Kaistra 2023-12-22 11:14:27 +01:00 committed by Kalle Valo
parent 00add60cad
commit 9aa776209c

View File

@ -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;