brcmfmac: move p2p attach/detach functions
authorArend van Spriel <arend@broadcom.com>
Wed, 10 Jun 2015 22:12:22 +0000 (00:12 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 15 Jun 2015 09:55:24 +0000 (12:55 +0300)
Moving two functions in p2p.c as is so next change will be
easier to review.

Reviewed-by: Hante Meuleman <meuleman@broadcom.com>
Reviewed-by: Franky (Zhenhui) Lin <frankyl@broadcom.com>
Reviewed-by: Pieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: Arend van Spriel <arend@broadcom.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/brcm80211/brcmfmac/p2p.c

index abcaa777c5e04a4c547f0d4e5149739e011abb20..920fcd9c9c16ef7d3ab28be7fd1a4e628b999915 100644 (file)
@@ -1907,105 +1907,6 @@ s32 brcmf_p2p_notify_rx_mgmt_p2p_probereq(struct brcmf_if *ifp,
 }
 
 
-/**
- * brcmf_p2p_attach() - attach for P2P.
- *
- * @cfg: driver private data for cfg80211 interface.
- */
-s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg)
-{
-       struct brcmf_if *pri_ifp;
-       struct brcmf_if *p2p_ifp;
-       struct brcmf_cfg80211_vif *p2p_vif;
-       struct brcmf_p2p_info *p2p;
-       struct brcmf_pub *drvr;
-       s32 bssidx;
-       s32 err = 0;
-
-       p2p = &cfg->p2p;
-       p2p->cfg = cfg;
-
-       drvr = cfg->pub;
-
-       pri_ifp = drvr->iflist[0];
-       p2p_ifp = drvr->iflist[1];
-
-       p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif = pri_ifp->vif;
-
-       if (p2p_ifp) {
-               p2p_vif = brcmf_alloc_vif(cfg, NL80211_IFTYPE_P2P_DEVICE,
-                                         false);
-               if (IS_ERR(p2p_vif)) {
-                       brcmf_err("could not create discovery vif\n");
-                       err = -ENOMEM;
-                       goto exit;
-               }
-
-               p2p_vif->ifp = p2p_ifp;
-               p2p_ifp->vif = p2p_vif;
-               p2p_vif->wdev.netdev = p2p_ifp->ndev;
-               p2p_ifp->ndev->ieee80211_ptr = &p2p_vif->wdev;
-               SET_NETDEV_DEV(p2p_ifp->ndev, wiphy_dev(cfg->wiphy));
-
-               p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = p2p_vif;
-
-               brcmf_p2p_generate_bss_mac(p2p, NULL);
-               memcpy(p2p_ifp->mac_addr, p2p->dev_addr, ETH_ALEN);
-               brcmf_p2p_set_firmware(pri_ifp, p2p->dev_addr);
-
-               /* Initialize P2P Discovery in the firmware */
-               err = brcmf_fil_iovar_int_set(pri_ifp, "p2p_disc", 1);
-               if (err < 0) {
-                       brcmf_err("set p2p_disc error\n");
-                       brcmf_free_vif(p2p_vif);
-                       goto exit;
-               }
-               /* obtain bsscfg index for P2P discovery */
-               err = brcmf_fil_iovar_int_get(pri_ifp, "p2p_dev", &bssidx);
-               if (err < 0) {
-                       brcmf_err("retrieving discover bsscfg index failed\n");
-                       brcmf_free_vif(p2p_vif);
-                       goto exit;
-               }
-               /* Verify that firmware uses same bssidx as driver !! */
-               if (p2p_ifp->bssidx != bssidx) {
-                       brcmf_err("Incorrect bssidx=%d, compared to p2p_ifp->bssidx=%d\n",
-                                 bssidx, p2p_ifp->bssidx);
-                       brcmf_free_vif(p2p_vif);
-                       goto exit;
-               }
-
-               init_completion(&p2p->send_af_done);
-               INIT_WORK(&p2p->afx_hdl.afx_work, brcmf_p2p_afx_handler);
-               init_completion(&p2p->afx_hdl.act_frm_scan);
-               init_completion(&p2p->wait_next_af);
-       }
-exit:
-       return err;
-}
-
-
-/**
- * brcmf_p2p_detach() - detach P2P.
- *
- * @p2p: P2P specific data.
- */
-void brcmf_p2p_detach(struct brcmf_p2p_info *p2p)
-{
-       struct brcmf_cfg80211_vif *vif;
-
-       vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
-       if (vif != NULL) {
-               brcmf_p2p_cancel_remain_on_channel(vif->ifp);
-               brcmf_p2p_deinit_discovery(p2p);
-               /* remove discovery interface */
-               brcmf_free_vif(vif);
-               p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL;
-       }
-       /* just set it all to zero */
-       memset(p2p, 0, sizeof(*p2p));
-}
-
 /**
  * brcmf_p2p_get_current_chanspec() - Get current operation channel.
  *
@@ -2428,3 +2329,102 @@ void brcmf_p2p_stop_device(struct wiphy *wiphy, struct wireless_dev *wdev)
        clear_bit(BRCMF_VIF_STATUS_READY, &vif->sme_state);
        mutex_unlock(&cfg->usr_sync);
 }
+
+/**
+ * brcmf_p2p_attach() - attach for P2P.
+ *
+ * @cfg: driver private data for cfg80211 interface.
+ */
+s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg)
+{
+       struct brcmf_if *pri_ifp;
+       struct brcmf_if *p2p_ifp;
+       struct brcmf_cfg80211_vif *p2p_vif;
+       struct brcmf_p2p_info *p2p;
+       struct brcmf_pub *drvr;
+       s32 bssidx;
+       s32 err = 0;
+
+       p2p = &cfg->p2p;
+       p2p->cfg = cfg;
+
+       drvr = cfg->pub;
+
+       pri_ifp = drvr->iflist[0];
+       p2p_ifp = drvr->iflist[1];
+
+       p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif = pri_ifp->vif;
+
+       if (p2p_ifp) {
+               p2p_vif = brcmf_alloc_vif(cfg, NL80211_IFTYPE_P2P_DEVICE,
+                                         false);
+               if (IS_ERR(p2p_vif)) {
+                       brcmf_err("could not create discovery vif\n");
+                       err = -ENOMEM;
+                       goto exit;
+               }
+
+               p2p_vif->ifp = p2p_ifp;
+               p2p_ifp->vif = p2p_vif;
+               p2p_vif->wdev.netdev = p2p_ifp->ndev;
+               p2p_ifp->ndev->ieee80211_ptr = &p2p_vif->wdev;
+               SET_NETDEV_DEV(p2p_ifp->ndev, wiphy_dev(cfg->wiphy));
+
+               p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = p2p_vif;
+
+               brcmf_p2p_generate_bss_mac(p2p, NULL);
+               memcpy(p2p_ifp->mac_addr, p2p->dev_addr, ETH_ALEN);
+               brcmf_p2p_set_firmware(pri_ifp, p2p->dev_addr);
+
+               /* Initialize P2P Discovery in the firmware */
+               err = brcmf_fil_iovar_int_set(pri_ifp, "p2p_disc", 1);
+               if (err < 0) {
+                       brcmf_err("set p2p_disc error\n");
+                       brcmf_free_vif(p2p_vif);
+                       goto exit;
+               }
+               /* obtain bsscfg index for P2P discovery */
+               err = brcmf_fil_iovar_int_get(pri_ifp, "p2p_dev", &bssidx);
+               if (err < 0) {
+                       brcmf_err("retrieving discover bsscfg index failed\n");
+                       brcmf_free_vif(p2p_vif);
+                       goto exit;
+               }
+               /* Verify that firmware uses same bssidx as driver !! */
+               if (p2p_ifp->bssidx != bssidx) {
+                       brcmf_err("Incorrect bssidx=%d, compared to p2p_ifp->bssidx=%d\n",
+                                 bssidx, p2p_ifp->bssidx);
+                       brcmf_free_vif(p2p_vif);
+                       goto exit;
+               }
+
+               init_completion(&p2p->send_af_done);
+               INIT_WORK(&p2p->afx_hdl.afx_work, brcmf_p2p_afx_handler);
+               init_completion(&p2p->afx_hdl.act_frm_scan);
+               init_completion(&p2p->wait_next_af);
+       }
+exit:
+       return err;
+}
+
+/**
+ * brcmf_p2p_detach() - detach P2P.
+ *
+ * @p2p: P2P specific data.
+ */
+void brcmf_p2p_detach(struct brcmf_p2p_info *p2p)
+{
+       struct brcmf_cfg80211_vif *vif;
+
+       vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
+       if (vif != NULL) {
+               brcmf_p2p_cancel_remain_on_channel(vif->ifp);
+               brcmf_p2p_deinit_discovery(p2p);
+               /* remove discovery interface */
+               brcmf_free_vif(vif);
+               p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif = NULL;
+       }
+       /* just set it all to zero */
+       memset(p2p, 0, sizeof(*p2p));
+}
+