@@ -7655,16 +7655,15 @@ brcmf_dump_obss(struct brcmf_if *ifp, struct cca_msrmnt_query req,
int err;
buf = kzalloc(sizeof(char) * BRCMF_DCMD_MEDLEN, GFP_KERNEL);
- if (unlikely(!buf)) {
- brcmf_err("%s: buf alloc failed\n", __func__);
+ if (!buf)
return -ENOMEM;
- }
memcpy(buf, &req, sizeof(struct cca_msrmnt_query));
err = brcmf_fil_iovar_data_get(ifp, "dump_obss",
buf, BRCMF_DCMD_MEDLEN);
- if (err < 0) {
+ if (err) {
brcmf_err("dump_obss error (%d)\n", err);
+ err = -EINVAL;
goto exit;
}
results = (struct cca_stats_n_flags *)(buf);
@@ -7672,11 +7671,9 @@ brcmf_dump_obss(struct brcmf_if *ifp, struct cca_msrmnt_query req,
if (req.msrmnt_query)
brcmf_parse_dump_obss(results->buf, survey);
- kfree(buf);
- return 0;
exit:
kfree(buf);
- return -EINVAL;
+ return err;
}
static s32
@@ -7713,7 +7710,7 @@ brcmf_cfg80211_dump_survey(struct wiphy *wiphy, struct net_device *ndev,
struct ieee80211_supported_band *band;
struct ieee80211_channel *chan;
struct cca_msrmnt_query req;
- u32 val, noise;
+ u32 noise;
int err;
brcmf_dbg(TRACE, "Enter: channel idx=%d\n", idx);
@@ -7739,31 +7736,27 @@ brcmf_cfg80211_dump_survey(struct wiphy *wiphy, struct net_device *ndev,
return 0;
}
- if (!idx) {
- /* Disable mpc */
- val = 0;
- brcmf_set_mpc(ifp, val);
- /* Set interface up, explicitly. */
- val = 1;
- err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, val);
- if (err) {
- brcmf_err("BRCMF_C_UP error (%d)\n", err);
- return -EIO;
- }
+ survey = kzalloc(sizeof(*survey), GFP_KERNEL);
+ if (!survey)
+ return -ENOMEM;
+
+ /* Disable mpc */
+ brcmf_set_mpc(ifp, 0);
+
+ /* Set interface up, explicitly. */
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);
+ if (err) {
+ brcmf_err("set interface up failed, err = %d\n", err);
+ goto exit;
}
/* Get noise value */
err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_PHY_NOISE, &noise);
if (err) {
- brcmf_err("Get Phy Noise failed, error = %d\n", err);
+ brcmf_err("Get Phy Noise failed, use dummy value\n");
noise = CHAN_NOISE_DUMMY;
}
- survey = kzalloc(sizeof(*survey), GFP_KERNEL);
- if (unlikely(!survey)) {
- brcmf_err("%s: alloc failed\n", __func__);
- return -ENOMEM;
- }
/* Start Measurement for obss stats on current channel */
req.msrmnt_query = 0;
@@ -7778,7 +7771,7 @@ brcmf_cfg80211_dump_survey(struct wiphy *wiphy, struct net_device *ndev,
/* Issue IOVAR to collect measurement results */
req.msrmnt_query = 1;
err = brcmf_dump_obss(ifp, req, survey);
- if (err < 0)
+ if (err)
goto exit;
info->channel = chan;
@@ -7798,9 +7791,9 @@ brcmf_cfg80211_dump_survey(struct wiphy *wiphy, struct net_device *ndev,
brcmf_dbg(INFO, "noise(%d) busy(%llu) rx(%llu) tx(%llu)\n",
info->noise, info->time_busy, info->time_rx, info->time_tx);
- kfree(survey);
- return 0;
exit:
+ if (!brcmf_is_apmode(ifp->vif))
+ brcmf_set_mpc(ifp, 1);
kfree(survey);
return err;
}