[PATCH v1 2/3] wifi: brcm80211: separate abort scan param prepare from actual scan

From: Petr Tesarik
Date: Tue Aug 01 2023 - 11:38:28 EST


From: Petr Tesarik <petr.tesarik.ext@xxxxxxxxxx>

Use a dedicated helper to prepare parameters for a scan abort, rather than
special-casing a NULL argument to brcmf_escan_prep().

Signed-off-by: Petr Tesarik <petr.tesarik.ext@xxxxxxxxxx>
---
.../broadcom/brcm80211/brcmfmac/cfg80211.c | 49 ++++++++++---------
1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
index de8a2e27f49c..3f4257fe76b3 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
@@ -1073,6 +1073,31 @@ static void brcmf_scan_params_v2_to_v1(struct brcmf_scan_params_v2_le *params_v2
&params_v2_le->channel_list[0], params_size);
}

+static void brcmf_escan_base_prep(struct brcmf_scan_params_v2_le *params_le)
+{
+ eth_broadcast_addr(params_le->bssid);
+
+ params_le->version = cpu_to_le16(BRCMF_SCAN_PARAMS_VERSION_V2);
+ params_le->bss_type = DOT11_BSSTYPE_ANY;
+ params_le->scan_type = cpu_to_le32(BRCMF_SCANTYPE_ACTIVE);
+ params_le->channel_num = 0;
+ params_le->nprobes = cpu_to_le32(-1);
+ params_le->active_time = cpu_to_le32(-1);
+ params_le->passive_time = cpu_to_le32(-1);
+ params_le->home_time = cpu_to_le32(-1);
+ memset(&params_le->ssid_le, 0, sizeof(params_le->ssid_le));
+}
+
+static void brcmf_escan_abort_prep(struct brcmf_scan_params_v2_le *params_le)
+{
+ int length = BRCMF_SCAN_PARAMS_V2_FIXED_SIZE + sizeof(u16);
+
+ brcmf_escan_base_prep(params_le);
+ params_le->channel_num = cpu_to_le32(1);
+ params_le->channel_list[0] = cpu_to_le16(-1);
+ params_le->length = cpu_to_le16(length);
+}
+
static void brcmf_escan_prep(struct brcmf_cfg80211_info *cfg,
struct brcmf_scan_params_v2_le *params_le,
struct cfg80211_scan_request *request)
@@ -1086,29 +1111,9 @@ static void brcmf_escan_prep(struct brcmf_cfg80211_info *cfg,
int length;
struct brcmf_ssid_le ssid_le;

- eth_broadcast_addr(params_le->bssid);
-
+ brcmf_escan_base_prep(params_le);
length = BRCMF_SCAN_PARAMS_V2_FIXED_SIZE;

- params_le->version = cpu_to_le16(BRCMF_SCAN_PARAMS_VERSION_V2);
- params_le->bss_type = DOT11_BSSTYPE_ANY;
- params_le->scan_type = cpu_to_le32(BRCMF_SCANTYPE_ACTIVE);
- params_le->channel_num = 0;
- params_le->nprobes = cpu_to_le32(-1);
- params_le->active_time = cpu_to_le32(-1);
- params_le->passive_time = cpu_to_le32(-1);
- params_le->home_time = cpu_to_le32(-1);
- memset(&params_le->ssid_le, 0, sizeof(params_le->ssid_le));
-
- /* Scan abort */
- if (!request) {
- length += sizeof(u16);
- params_le->channel_num = cpu_to_le32(1);
- params_le->channel_list[0] = cpu_to_le16(-1);
- params_le->length = cpu_to_le16(length);
- return;
- }
-
n_ssids = request->n_ssids;
n_channels = request->n_channels;

@@ -1186,7 +1191,7 @@ s32 brcmf_notify_escan_complete(struct brcmf_cfg80211_info *cfg,
/* Do a scan abort to stop the driver's scan engine */
brcmf_dbg(SCAN, "ABORT scan in firmware\n");

- brcmf_escan_prep(cfg, &params_v2_le, NULL);
+ brcmf_escan_abort_prep(&params_v2_le);

/* E-Scan (or anyother type) can be aborted by SCAN */
if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_SCAN_V2)) {
--
2.25.1