Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ccfd1e81 authored by Arend van Spriel's avatar Arend van Spriel Committed by John W. Linville
Browse files

brcmfmac: move attach and detach functions in wl_cfg80211.c



Preparing for another patch move the functions in separate commit.

Reviewed-by: default avatarHante Meuleman <meuleman@broadcom.com>
Reviewed-by: default avatarDaniel (Deognyoun) Kim <dekim@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 c1b20532
Loading
Loading
Loading
Loading
+107 −108
Original line number Diff line number Diff line
@@ -4967,114 +4967,6 @@ static int brcmf_enable_bw40_2g(struct brcmf_if *ifp)
	return err;
}

struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
						  struct device *busdev)
{
	struct net_device *ndev = drvr->iflist[0]->ndev;
	struct brcmf_cfg80211_info *cfg;
	struct wiphy *wiphy;
	struct brcmf_cfg80211_vif *vif;
	struct brcmf_if *ifp;
	s32 err = 0;
	s32 io_type;

	if (!ndev) {
		brcmf_err("ndev is invalid\n");
		return NULL;
	}

	ifp = netdev_priv(ndev);
	wiphy = brcmf_setup_wiphy(busdev);
	if (IS_ERR(wiphy))
		return NULL;

	cfg = wiphy_priv(wiphy);
	cfg->wiphy = wiphy;
	cfg->pub = drvr;
	init_vif_event(&cfg->vif_event);
	INIT_LIST_HEAD(&cfg->vif_list);

	vif = brcmf_alloc_vif(cfg, NL80211_IFTYPE_STATION, false);
	if (IS_ERR(vif)) {
		wiphy_free(wiphy);
		return NULL;
	}

	vif->ifp = ifp;
	vif->wdev.netdev = ndev;
	ndev->ieee80211_ptr = &vif->wdev;
	SET_NETDEV_DEV(ndev, wiphy_dev(cfg->wiphy));

	err = wl_init_priv(cfg);
	if (err) {
		brcmf_err("Failed to init iwm_priv (%d)\n", err);
		goto cfg80211_attach_out;
	}
	ifp->vif = vif;

	err = brcmf_p2p_attach(cfg);
	if (err) {
		brcmf_err("P2P initilisation failed (%d)\n", err);
		goto cfg80211_p2p_attach_out;
	}
	err = brcmf_btcoex_attach(cfg);
	if (err) {
		brcmf_err("BT-coex initialisation failed (%d)\n", err);
		brcmf_p2p_detach(&cfg->p2p);
		goto cfg80211_p2p_attach_out;
	}

	/* If cfg80211 didn't disable 40MHz HT CAP in wiphy_register(),
	 * setup 40MHz in 2GHz band and enable OBSS scanning.
	 */
	if (wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap.cap &
	    IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
		err = brcmf_enable_bw40_2g(ifp);
		if (!err)
			err = brcmf_fil_iovar_int_set(ifp, "obss_coex",
						      BRCMF_OBSS_COEX_AUTO);
	}
	/* clear for now and rely on update later */
	wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap.ht_supported = false;
	wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap.cap = 0;

	err = brcmf_fil_iovar_int_set(ifp, "tdls_enable", 1);
	if (err) {
		brcmf_dbg(INFO, "TDLS not enabled (%d)\n", err);
		wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_TDLS;
	}

	err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION,
				    &io_type);
	if (err) {
		brcmf_err("Failed to get D11 version (%d)\n", err);
		goto cfg80211_p2p_attach_out;
	}
	cfg->d11inf.io_type = (u8)io_type;
	brcmu_d11_attach(&cfg->d11inf);

	return cfg;

cfg80211_p2p_attach_out:
	wl_deinit_priv(cfg);

cfg80211_attach_out:
	brcmf_free_vif(vif);
	return NULL;
}

void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg)
{
	if (!cfg)
		return;

	WARN_ON(!list_empty(&cfg->vif_list));
	wiphy_unregister(cfg->wiphy);
	brcmf_btcoex_detach(cfg);
	wl_deinit_priv(cfg);
	wiphy_free(cfg->wiphy);
}

static s32
brcmf_dongle_roam(struct brcmf_if *ifp, u32 bcn_timeout)
{
@@ -5658,3 +5550,110 @@ int brcmf_cfg80211_wait_vif_event_timeout(struct brcmf_cfg80211_info *cfg,
				  vif_event_equals(event, action), timeout);
}

struct brcmf_cfg80211_info *brcmf_cfg80211_attach(struct brcmf_pub *drvr,
						  struct device *busdev)
{
	struct net_device *ndev = drvr->iflist[0]->ndev;
	struct brcmf_cfg80211_info *cfg;
	struct wiphy *wiphy;
	struct brcmf_cfg80211_vif *vif;
	struct brcmf_if *ifp;
	s32 err = 0;
	s32 io_type;

	if (!ndev) {
		brcmf_err("ndev is invalid\n");
		return NULL;
	}

	ifp = netdev_priv(ndev);
	wiphy = brcmf_setup_wiphy(busdev);
	if (IS_ERR(wiphy))
		return NULL;

	cfg = wiphy_priv(wiphy);
	cfg->wiphy = wiphy;
	cfg->pub = drvr;
	init_vif_event(&cfg->vif_event);
	INIT_LIST_HEAD(&cfg->vif_list);

	vif = brcmf_alloc_vif(cfg, NL80211_IFTYPE_STATION, false);
	if (IS_ERR(vif)) {
		wiphy_free(wiphy);
		return NULL;
	}

	vif->ifp = ifp;
	vif->wdev.netdev = ndev;
	ndev->ieee80211_ptr = &vif->wdev;
	SET_NETDEV_DEV(ndev, wiphy_dev(cfg->wiphy));

	err = wl_init_priv(cfg);
	if (err) {
		brcmf_err("Failed to init iwm_priv (%d)\n", err);
		goto cfg80211_attach_out;
	}
	ifp->vif = vif;

	err = brcmf_p2p_attach(cfg);
	if (err) {
		brcmf_err("P2P initilisation failed (%d)\n", err);
		goto cfg80211_p2p_attach_out;
	}
	err = brcmf_btcoex_attach(cfg);
	if (err) {
		brcmf_err("BT-coex initialisation failed (%d)\n", err);
		brcmf_p2p_detach(&cfg->p2p);
		goto cfg80211_p2p_attach_out;
	}

	/* If cfg80211 didn't disable 40MHz HT CAP in wiphy_register(),
	 * setup 40MHz in 2GHz band and enable OBSS scanning.
	 */
	if (wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap.cap &
	    IEEE80211_HT_CAP_SUP_WIDTH_20_40) {
		err = brcmf_enable_bw40_2g(ifp);
		if (!err)
			err = brcmf_fil_iovar_int_set(ifp, "obss_coex",
						      BRCMF_OBSS_COEX_AUTO);
	}
	/* clear for now and rely on update later */
	wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap.ht_supported = false;
	wiphy->bands[IEEE80211_BAND_2GHZ]->ht_cap.cap = 0;

	err = brcmf_fil_iovar_int_set(ifp, "tdls_enable", 1);
	if (err) {
		brcmf_dbg(INFO, "TDLS not enabled (%d)\n", err);
		wiphy->flags &= ~WIPHY_FLAG_SUPPORTS_TDLS;
	}

	err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION,
				    &io_type);
	if (err) {
		brcmf_err("Failed to get D11 version (%d)\n", err);
		goto cfg80211_p2p_attach_out;
	}
	cfg->d11inf.io_type = (u8)io_type;
	brcmu_d11_attach(&cfg->d11inf);

	return cfg;

cfg80211_p2p_attach_out:
	wl_deinit_priv(cfg);

cfg80211_attach_out:
	brcmf_free_vif(vif);
	return NULL;
}

void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg)
{
	if (!cfg)
		return;

	WARN_ON(!list_empty(&cfg->vif_list));
	wiphy_unregister(cfg->wiphy);
	brcmf_btcoex_detach(cfg);
	wl_deinit_priv(cfg);
	wiphy_free(cfg->wiphy);
}