39a19286ca64d1a1a3f3d5abdb242e2356ef5ee6
[oweals/openwrt.git] /
1 From 66ab63fbb33bf367807e3e471231379dce6f8b8c Mon Sep 17 00:00:00 2001
2 From: Arend van Spriel <arend.vanspriel@broadcom.com>
3 Date: Thu, 11 Jul 2019 11:05:10 +0200
4 Subject: [PATCH 5/7] brcmfmac: avoid firmware commands when bus is down
5
6 Upon rmmod a few attempts are made to inform firmware, but there is
7 no point as the bus is down and these will fail. Avoid them to keep
8 the logs clean.
9
10 Reported-by: Stefan Wahren <stefan.wahren@i2se.com>
11 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
12 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
13 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
14 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
15 ---
16  .../broadcom/brcm80211/brcmfmac/cfg80211.c    | 23 +++++++++++--------
17  1 file changed, 13 insertions(+), 10 deletions(-)
18
19 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
20 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
21 @@ -1388,17 +1388,21 @@ static void brcmf_link_down(struct brcmf
22  {
23         struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(vif->wdev.wiphy);
24         struct brcmf_pub *drvr = cfg->pub;
25 +       bool bus_up = drvr->bus_if->state == BRCMF_BUS_UP;
26         s32 err = 0;
27  
28         brcmf_dbg(TRACE, "Enter\n");
29  
30         if (test_and_clear_bit(BRCMF_VIF_STATUS_CONNECTED, &vif->sme_state)) {
31 -               brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n ");
32 -               err = brcmf_fil_cmd_data_set(vif->ifp,
33 -                                            BRCMF_C_DISASSOC, NULL, 0);
34 -               if (err) {
35 -                       bphy_err(drvr, "WLC_DISASSOC failed (%d)\n", err);
36 +               if (bus_up) {
37 +                       brcmf_dbg(INFO, "Call WLC_DISASSOC to stop excess roaming\n");
38 +                       err = brcmf_fil_cmd_data_set(vif->ifp,
39 +                                                    BRCMF_C_DISASSOC, NULL, 0);
40 +                       if (err)
41 +                               bphy_err(drvr, "WLC_DISASSOC failed (%d)\n",
42 +                                        err);
43                 }
44 +
45                 if ((vif->wdev.iftype == NL80211_IFTYPE_STATION) ||
46                     (vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT))
47                         cfg80211_disconnected(vif->wdev.netdev, reason, NULL, 0,
48 @@ -5041,18 +5045,16 @@ static int brcmf_cfg80211_get_channel(st
49         struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
50         struct net_device *ndev = wdev->netdev;
51         struct brcmf_pub *drvr = cfg->pub;
52 -       struct brcmf_if *ifp;
53         struct brcmu_chan ch;
54         enum nl80211_band band = 0;
55         enum nl80211_chan_width width = 0;
56         u32 chanspec;
57         int freq, err;
58  
59 -       if (!ndev)
60 +       if (!ndev || drvr->bus_if->state != BRCMF_BUS_UP)
61                 return -ENODEV;
62 -       ifp = netdev_priv(ndev);
63  
64 -       err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec);
65 +       err = brcmf_fil_iovar_int_get(netdev_priv(ndev), "chanspec", &chanspec);
66         if (err) {
67                 bphy_err(drvr, "chanspec failed (%d)\n", err);
68                 return err;