Skip to content

Commit

Permalink
ath6kl: create core.c
Browse files Browse the repository at this point in the history
Currently core functions are spread between various files, group all
the functions into file and rename the functions to follow the style
used elsewhere in the driver. This will make it easier to a separate core
module.

Also fix a bug where wiphy is freed too early.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
  • Loading branch information
Kalle Valo committed Jan 18, 2012
1 parent f29af97 commit 45eaa78
Show file tree
Hide file tree
Showing 8 changed files with 332 additions and 288 deletions.
1 change: 1 addition & 0 deletions drivers/net/wireless/ath/ath6kl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ ath6kl-y += init.o
ath6kl-y += main.o
ath6kl-y += txrx.o
ath6kl-y += wmi.o
ath6kl-y += core.o
ath6kl-y += sdio.o
ath6kl-$(CONFIG_NL80211_TESTMODE) += testmode.o
94 changes: 24 additions & 70 deletions drivers/net/wireless/ath/ath6kl/cfg80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
#include "hif-ops.h"
#include "testmode.h"

static unsigned int ath6kl_p2p;

module_param(ath6kl_p2p, uint, 0644);

#define RATETAB_ENT(_rate, _rateid, _flags) { \
.bitrate = (_rate), \
.flags = (_flags), \
Expand Down Expand Up @@ -2693,68 +2689,6 @@ void ath6kl_cfg80211_stop_all(struct ath6kl *ar)
ath6kl_cfg80211_stop(vif);
}

struct ath6kl *ath6kl_core_alloc(struct device *dev)
{
struct ath6kl *ar;
struct wiphy *wiphy;
u8 ctr;

/* create a new wiphy for use with cfg80211 */
wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl));

if (!wiphy) {
ath6kl_err("couldn't allocate wiphy device\n");
return NULL;
}

ar = wiphy_priv(wiphy);
ar->p2p = !!ath6kl_p2p;
ar->wiphy = wiphy;
ar->dev = dev;

ar->vif_max = 1;

ar->max_norm_iface = 1;

spin_lock_init(&ar->lock);
spin_lock_init(&ar->mcastpsq_lock);
spin_lock_init(&ar->list_lock);

init_waitqueue_head(&ar->event_wq);
sema_init(&ar->sem, 1);

INIT_LIST_HEAD(&ar->amsdu_rx_buffer_queue);
INIT_LIST_HEAD(&ar->vif_list);

clear_bit(WMI_ENABLED, &ar->flag);
clear_bit(SKIP_SCAN, &ar->flag);
clear_bit(DESTROY_IN_PROGRESS, &ar->flag);

ar->listen_intvl_b = A_DEFAULT_LISTEN_INTERVAL;
ar->tx_pwr = 0;

ar->intra_bss = 1;
ar->lrssi_roam_threshold = DEF_LRSSI_ROAM_THRESHOLD;

ar->state = ATH6KL_STATE_OFF;

memset((u8 *)ar->sta_list, 0,
AP_MAX_NUM_STA * sizeof(struct ath6kl_sta));

/* Init the PS queues */
for (ctr = 0; ctr < AP_MAX_NUM_STA; ctr++) {
spin_lock_init(&ar->sta_list[ctr].psq_lock);
skb_queue_head_init(&ar->sta_list[ctr].psq);
skb_queue_head_init(&ar->sta_list[ctr].apsdq);
}

skb_queue_head_init(&ar->mcastpsq);

memcpy(ar->ap_country_code, DEF_AP_COUNTRY_CODE, 3);

return ar;
}

static int ath6kl_cfg80211_vif_init(struct ath6kl_vif *vif)
{
vif->aggr_cntxt = aggr_init(vif->ndev);
Expand Down Expand Up @@ -2910,10 +2844,30 @@ int ath6kl_cfg80211_init(struct ath6kl *ar)
void ath6kl_cfg80211_cleanup(struct ath6kl *ar)
{
wiphy_unregister(ar->wiphy);
}

/*
* FIXME: should be removed as we remove wiphy in
* ath6kl_core_free(). Most likely this causes a use after free.
*/
struct ath6kl *ath6kl_cfg80211_create(void)
{
struct ath6kl *ar;
struct wiphy *wiphy;

/* create a new wiphy for use with cfg80211 */
wiphy = wiphy_new(&ath6kl_cfg80211_ops, sizeof(struct ath6kl));

if (!wiphy) {
ath6kl_err("couldn't allocate wiphy device\n");
return NULL;
}

ar = wiphy_priv(wiphy);
ar->wiphy = wiphy;

return ar;
}

/* Note: ar variable must not be accessed after calling this! */
void ath6kl_cfg80211_destroy(struct ath6kl *ar)
{
wiphy_free(ar->wiphy);
}

4 changes: 3 additions & 1 deletion drivers/net/wireless/ath/ath6kl/cfg80211.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ enum ath6kl_cfg_suspend_mode {
struct net_device *ath6kl_interface_add(struct ath6kl *ar, char *name,
enum nl80211_iftype type,
u8 fw_vif_idx, u8 nw_type);
struct ath6kl *ath6kl_core_alloc(struct device *dev);
void ath6kl_cfg80211_scan_complete_event(struct ath6kl_vif *vif, bool aborted);

void ath6kl_cfg80211_connect_event(struct ath6kl_vif *vif, u16 channel,
Expand Down Expand Up @@ -58,4 +57,7 @@ void ath6kl_cfg80211_stop_all(struct ath6kl *ar);
int ath6kl_cfg80211_init(struct ath6kl *ar);
void ath6kl_cfg80211_cleanup(struct ath6kl *ar);

struct ath6kl *ath6kl_cfg80211_create(void);
void ath6kl_cfg80211_destroy(struct ath6kl *ar);

#endif /* ATH6KL_CFG80211_H */
3 changes: 0 additions & 3 deletions drivers/net/wireless/ath/ath6kl/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,5 @@ struct ath6kl;
enum htc_credit_dist_reason;
struct ath6kl_htc_credit_info;

struct ath6kl *ath6kl_core_alloc(struct device *sdev);
int ath6kl_core_init(struct ath6kl *ar);
void ath6kl_core_cleanup(struct ath6kl *ar);
struct sk_buff *ath6kl_buf_alloc(int size);
#endif /* COMMON_H */
Loading

0 comments on commit 45eaa78

Please sign in to comment.