OSDN Git Service

wcn36xx: Track the band and channel we are tuned to
authorBryan O'Donoghue <bryan.odonoghue@linaro.org>
Sat, 15 Jan 2022 00:16:44 +0000 (00:16 +0000)
committerKalle Valo <quic_kvalo@quicinc.com>
Wed, 19 Jan 2022 08:49:15 +0000 (10:49 +0200)
Track the band and channel we are currently tuned to by way of pointers to
the standard structures that describe them both embedded within the driver.

Tracking of the pair makes it much easier when implementing
ieee80211_ops->get_survey to return quickly captured metrics for the
currently tuned channel.

Signed-off-by: Bryan O'Donoghue <bryan.odonoghue@linaro.org>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220115001646.3981501-3-bryan.odonoghue@linaro.org
drivers/net/wireless/ath/wcn36xx/main.c
drivers/net/wireless/ath/wcn36xx/wcn36xx.h

index bd334a3..bb674b7 100644 (file)
@@ -392,11 +392,38 @@ static void wcn36xx_change_opchannel(struct wcn36xx *wcn, int ch)
 {
        struct ieee80211_vif *vif = NULL;
        struct wcn36xx_vif *tmp;
+       struct ieee80211_supported_band *band;
+       struct ieee80211_channel *channel;
+       int i, j;
+
+       for (i = 0; i < ARRAY_SIZE(wcn->hw->wiphy->bands); i++) {
+               band = wcn->hw->wiphy->bands[i];
+               if (!band)
+                       break;
+               for (j = 0; j < band->n_channels; j++) {
+                       if (HW_VALUE_CHANNEL(band->channels[j].hw_value) == ch) {
+                               channel = &band->channels[j];
+                               break;
+                       }
+               }
+               if (channel)
+                       break;
+       }
+
+       if (!channel) {
+               wcn36xx_err("Cannot tune to channel %d\n", ch);
+               return;
+       }
+
+       wcn->band = band;
+       wcn->channel = channel;
 
        list_for_each_entry(tmp, &wcn->vif_list, list) {
                vif = wcn36xx_priv_to_vif(tmp);
                wcn36xx_smd_switch_channel(wcn, vif, ch);
        }
+
+       return;
 }
 
 static int wcn36xx_config(struct ieee80211_hw *hw, u32 changed)
index fbd0558..dd2570e 100644 (file)
@@ -281,6 +281,9 @@ struct wcn36xx {
        /* Debug file system entry */
        struct wcn36xx_dfs_entry    dfs;
 #endif /* CONFIG_WCN36XX_DEBUGFS */
+
+       struct ieee80211_supported_band *band;
+       struct ieee80211_channel *channel;
 };
 
 static inline bool wcn36xx_is_fw_version(struct wcn36xx *wcn,