1 From 701fb69f2c36cba83583990e67a3925f920fd96a 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 2/7] brcmfmac: change the order of things in brcmf_detach()
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
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.
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>
22 .../broadcom/brcm80211/brcmfmac/core.c | 27 ++++++++++---------
23 1 file changed, 14 insertions(+), 13 deletions(-)
25 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
26 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
27 @@ -1337,25 +1337,26 @@ void brcmf_detach(struct device *dev)
28 unregister_inet6addr_notifier(&drvr->inet6addr_notifier);
31 - /* stop firmware event handling */
32 - brcmf_fweh_detach(drvr);
34 - brcmf_p2p_detach(&drvr->config->p2p);
36 brcmf_bus_change_state(bus_if, BRCMF_BUS_DOWN);
38 - /* make sure primary interface removed last */
39 - for (i = BRCMF_MAX_IFS-1; i > -1; i--)
40 - brcmf_remove_interface(drvr->iflist[i], false);
42 - brcmf_cfg80211_detach(drvr->config);
43 - drvr->config = NULL;
45 brcmf_bus_stop(drvr->bus_if);
47 + brcmf_fweh_detach(drvr);
48 brcmf_proto_detach(drvr);
50 + /* make sure primary interface removed last */
51 + for (i = BRCMF_MAX_IFS - 1; i > -1; i--) {
52 + if (drvr->iflist[i])
53 + brcmf_del_if(drvr, drvr->iflist[i]->bsscfgidx, false);
57 + brcmf_p2p_detach(&drvr->config->p2p);
58 + brcmf_cfg80211_detach(drvr->config);
59 + drvr->config = NULL;
64 wiphy_free(drvr->wiphy);