d40bf031b88bcf87eb6c6163ffece348de3ff080
[openwrt/staging/blocktrron.git] /
1 From 14fcfd1cc0c05ea58f47dd693fdd13f25dfe995e Mon Sep 17 00:00:00 2001
2 From: Arend van Spriel <arend.vanspriel@broadcom.com>
3 Date: Thu, 11 Jul 2019 11:05:07 +0200
4 Subject: [PATCH] brcmfmac: change the order of things in brcmf_detach()
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 When brcmf_detach() from the bus layer upon rmmod we can no longer
10 communicate. Hence we will set the bus state to DOWN and cleanup
11 the event and protocol layer. The network interfaces need to be
12 deleted before brcmf_cfg80211_detach() because the latter does the
13 wiphy_unregister() which issues a warning if there are still network
14 devices linked to the wiphy instance.
15
16 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
17 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
18 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
19 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
20 Tested-by: Rafał Miłecki <rafal@milecki.pl>
21 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
22 ---
23 .../broadcom/brcm80211/brcmfmac/core.c | 27 ++++++++++---------
24 1 file changed, 14 insertions(+), 13 deletions(-)
25
26 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
27 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
28 @@ -1328,25 +1328,26 @@ void brcmf_detach(struct device *dev)
29 unregister_inet6addr_notifier(&drvr->inet6addr_notifier);
30 #endif
31
32 - /* stop firmware event handling */
33 - brcmf_fweh_detach(drvr);
34 - if (drvr->config)
35 - brcmf_p2p_detach(&drvr->config->p2p);
36 -
37 brcmf_bus_change_state(bus_if, BRCMF_BUS_DOWN);
38 -
39 - /* make sure primary interface removed last */
40 - for (i = BRCMF_MAX_IFS-1; i > -1; i--)
41 - brcmf_remove_interface(drvr->iflist[i], false);
42 -
43 - brcmf_cfg80211_detach(drvr->config);
44 - drvr->config = NULL;
45 -
46 brcmf_bus_stop(drvr->bus_if);
47
48 + brcmf_fweh_detach(drvr);
49 brcmf_proto_detach(drvr);
50
51 + /* make sure primary interface removed last */
52 + for (i = BRCMF_MAX_IFS - 1; i > -1; i--) {
53 + if (drvr->iflist[i])
54 + brcmf_del_if(drvr, drvr->iflist[i]->bsscfgidx, false);
55 + }
56 +
57 + if (drvr->config) {
58 + brcmf_p2p_detach(&drvr->config->p2p);
59 + brcmf_cfg80211_detach(drvr->config);
60 + drvr->config = NULL;
61 + }
62 +
63 bus_if->drvr = NULL;
64 +
65 wiphy_free(drvr->wiphy);
66 }
67