Commit 427dec5f authored by Arend van Spriel's avatar Arend van Spriel Committed by John W. Linville

brcmfmac: move wiphy_unregister() call to brcmf_cfg80211_detach()

The wiphy_unregister() call was done in brcmf_free_vif() when the
last interface was being removed. This is not the obvious place to
do that. This patch moves it to the brcmf_cfg80211_detach(). This
removes the need to keep count of interfaces.
Reviewed-by: default avatarHante Meuleman <meuleman@broadcom.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 43dffbc6
...@@ -1956,21 +1956,21 @@ s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg) ...@@ -1956,21 +1956,21 @@ s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg)
err = brcmf_fil_iovar_int_set(pri_ifp, "p2p_disc", 1); err = brcmf_fil_iovar_int_set(pri_ifp, "p2p_disc", 1);
if (err < 0) { if (err < 0) {
brcmf_err("set p2p_disc error\n"); brcmf_err("set p2p_disc error\n");
brcmf_free_vif(cfg, p2p_vif); brcmf_free_vif(p2p_vif);
goto exit; goto exit;
} }
/* obtain bsscfg index for P2P discovery */ /* obtain bsscfg index for P2P discovery */
err = brcmf_fil_iovar_int_get(pri_ifp, "p2p_dev", &bssidx); err = brcmf_fil_iovar_int_get(pri_ifp, "p2p_dev", &bssidx);
if (err < 0) { if (err < 0) {
brcmf_err("retrieving discover bsscfg index failed\n"); brcmf_err("retrieving discover bsscfg index failed\n");
brcmf_free_vif(cfg, p2p_vif); brcmf_free_vif(p2p_vif);
goto exit; goto exit;
} }
/* Verify that firmware uses same bssidx as driver !! */ /* Verify that firmware uses same bssidx as driver !! */
if (p2p_ifp->bssidx != bssidx) { if (p2p_ifp->bssidx != bssidx) {
brcmf_err("Incorrect bssidx=%d, compared to p2p_ifp->bssidx=%d\n", brcmf_err("Incorrect bssidx=%d, compared to p2p_ifp->bssidx=%d\n",
bssidx, p2p_ifp->bssidx); bssidx, p2p_ifp->bssidx);
brcmf_free_vif(cfg, p2p_vif); brcmf_free_vif(p2p_vif);
goto exit; goto exit;
} }
...@@ -1998,7 +1998,7 @@ void brcmf_p2p_detach(struct brcmf_p2p_info *p2p) ...@@ -1998,7 +1998,7 @@ void brcmf_p2p_detach(struct brcmf_p2p_info *p2p)
brcmf_p2p_cancel_remain_on_channel(vif->ifp); brcmf_p2p_cancel_remain_on_channel(vif->ifp);
brcmf_p2p_deinit_discovery(p2p); brcmf_p2p_deinit_discovery(p2p);
/* remove discovery interface */ /* remove discovery interface */
brcmf_free_vif(p2p->cfg, vif); brcmf_free_vif(vif);
p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL; p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL;
} }
/* just set it all to zero */ /* just set it all to zero */
...@@ -2223,7 +2223,7 @@ static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p, ...@@ -2223,7 +2223,7 @@ static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p,
return &p2p_vif->wdev; return &p2p_vif->wdev;
fail: fail:
brcmf_free_vif(p2p->cfg, p2p_vif); brcmf_free_vif(p2p_vif);
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -2232,12 +2232,12 @@ static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p, ...@@ -2232,12 +2232,12 @@ static struct wireless_dev *brcmf_p2p_create_p2pdev(struct brcmf_p2p_info *p2p,
* *
* @vif: virtual interface object to delete. * @vif: virtual interface object to delete.
*/ */
static void brcmf_p2p_delete_p2pdev(struct brcmf_cfg80211_info *cfg, static void brcmf_p2p_delete_p2pdev(struct brcmf_p2p_info *p2p,
struct brcmf_cfg80211_vif *vif) struct brcmf_cfg80211_vif *vif)
{ {
cfg80211_unregister_wdev(&vif->wdev); cfg80211_unregister_wdev(&vif->wdev);
cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL; p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL;
brcmf_free_vif(cfg, vif); brcmf_free_vif(vif);
} }
/** /**
...@@ -2247,15 +2247,13 @@ static void brcmf_p2p_delete_p2pdev(struct brcmf_cfg80211_info *cfg, ...@@ -2247,15 +2247,13 @@ static void brcmf_p2p_delete_p2pdev(struct brcmf_cfg80211_info *cfg,
*/ */
static void brcmf_p2p_free_p2p_if(struct net_device *ndev) static void brcmf_p2p_free_p2p_if(struct net_device *ndev)
{ {
struct brcmf_cfg80211_info *cfg;
struct brcmf_cfg80211_vif *vif; struct brcmf_cfg80211_vif *vif;
struct brcmf_if *ifp; struct brcmf_if *ifp;
ifp = netdev_priv(ndev); ifp = netdev_priv(ndev);
cfg = ifp->drvr->config;
vif = ifp->vif; vif = ifp->vif;
brcmf_free_vif(cfg, vif); brcmf_free_vif(vif);
free_netdev(ifp->ndev); free_netdev(ifp->ndev);
} }
...@@ -2350,7 +2348,7 @@ struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name, ...@@ -2350,7 +2348,7 @@ struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name,
return &ifp->vif->wdev; return &ifp->vif->wdev;
fail: fail:
brcmf_free_vif(cfg, vif); brcmf_free_vif(vif);
return ERR_PTR(err); return ERR_PTR(err);
} }
...@@ -2359,8 +2357,6 @@ struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name, ...@@ -2359,8 +2357,6 @@ struct wireless_dev *brcmf_p2p_add_vif(struct wiphy *wiphy, const char *name,
* *
* @wiphy: wiphy device of interface. * @wiphy: wiphy device of interface.
* @wdev: wireless device of interface. * @wdev: wireless device of interface.
*
* TODO: not yet supported.
*/ */
int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev)
{ {
...@@ -2386,7 +2382,7 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev) ...@@ -2386,7 +2382,7 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy, struct wireless_dev *wdev)
break; break;
case NL80211_IFTYPE_P2P_DEVICE: case NL80211_IFTYPE_P2P_DEVICE:
brcmf_p2p_delete_p2pdev(cfg, vif); brcmf_p2p_delete_p2pdev(p2p, vif);
return 0; return 0;
default: default:
return -ENOTSUPP; return -ENOTSUPP;
......
...@@ -4360,9 +4360,6 @@ struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg, ...@@ -4360,9 +4360,6 @@ struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
{ {
struct brcmf_cfg80211_vif *vif; struct brcmf_cfg80211_vif *vif;
if (cfg->vif_cnt == BRCMF_IFACE_MAX_CNT)
return ERR_PTR(-ENOSPC);
brcmf_dbg(TRACE, "allocating virtual interface (size=%zu)\n", brcmf_dbg(TRACE, "allocating virtual interface (size=%zu)\n",
sizeof(*vif)); sizeof(*vif));
vif = kzalloc(sizeof(*vif), GFP_KERNEL); vif = kzalloc(sizeof(*vif), GFP_KERNEL);
...@@ -4379,21 +4376,13 @@ struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg, ...@@ -4379,21 +4376,13 @@ struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
brcmf_init_prof(&vif->profile); brcmf_init_prof(&vif->profile);
list_add_tail(&vif->list, &cfg->vif_list); list_add_tail(&vif->list, &cfg->vif_list);
cfg->vif_cnt++;
return vif; return vif;
} }
void brcmf_free_vif(struct brcmf_cfg80211_info *cfg, void brcmf_free_vif(struct brcmf_cfg80211_vif *vif)
struct brcmf_cfg80211_vif *vif)
{ {
list_del(&vif->list); list_del(&vif->list);
cfg->vif_cnt--;
kfree(vif); kfree(vif);
if (!cfg->vif_cnt) {
wiphy_unregister(cfg->wiphy);
wiphy_free(cfg->wiphy);
}
} }
static bool brcmf_is_linkup(const struct brcmf_event_msg *e) static bool brcmf_is_linkup(const struct brcmf_event_msg *e)
...@@ -4980,20 +4969,17 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr, ...@@ -4980,20 +4969,17 @@ struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
wl_deinit_priv(cfg); wl_deinit_priv(cfg);
cfg80211_attach_out: cfg80211_attach_out:
brcmf_free_vif(cfg, vif); brcmf_free_vif(vif);
return NULL; return NULL;
} }
void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg) void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg)
{ {
struct brcmf_cfg80211_vif *vif; WARN_ON(!list_empty(&cfg->vif_list));
struct brcmf_cfg80211_vif *tmp; wiphy_unregister(cfg->wiphy);
wl_deinit_priv(cfg);
brcmf_btcoex_detach(cfg); brcmf_btcoex_detach(cfg);
list_for_each_entry_safe(vif, tmp, &cfg->vif_list, list) { wl_deinit_priv(cfg);
brcmf_free_vif(cfg, vif); wiphy_free(cfg->wiphy);
}
} }
static s32 static s32
......
...@@ -412,7 +412,6 @@ struct brcmf_cfg80211_info { ...@@ -412,7 +412,6 @@ struct brcmf_cfg80211_info {
struct work_struct escan_timeout_work; struct work_struct escan_timeout_work;
u8 *escan_ioctl_buf; u8 *escan_ioctl_buf;
struct list_head vif_list; struct list_head vif_list;
u8 vif_cnt;
struct brcmf_cfg80211_vif_event vif_event; struct brcmf_cfg80211_vif_event vif_event;
struct completion vif_disabled; struct completion vif_disabled;
struct brcmu_d11inf d11inf; struct brcmu_d11inf d11inf;
...@@ -487,8 +486,7 @@ enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp); ...@@ -487,8 +486,7 @@ enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg, struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
enum nl80211_iftype type, enum nl80211_iftype type,
bool pm_block); bool pm_block);
void brcmf_free_vif(struct brcmf_cfg80211_info *cfg, void brcmf_free_vif(struct brcmf_cfg80211_vif *vif);
struct brcmf_cfg80211_vif *vif);
s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag, s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
const u8 *vndr_ie_buf, u32 vndr_ie_len); const u8 *vndr_ie_buf, u32 vndr_ie_len);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment