diff options
author | Johannes Berg <johannes.berg@intel.com> | 2010-10-04 08:50:36 -0400 |
---|---|---|
committer | Wey-Yi Guy <wey-yi.w.guy@intel.com> | 2010-10-14 12:46:50 -0400 |
commit | 77834543a5278b55df6c2784cd5ed59970be3c44 (patch) | |
tree | 9b1be00ee2aed98564ca3ce7aa0179764dcf43e4 /drivers/net/wireless | |
parent | 12e934dc602fafba946b33587c38077ebceb3698 (diff) |
iwlwifi: clean up some beacon handling
There's no need to check for NULL before
calling dev_kfree_skb() since it is valid
to call it on NULL -- it becomes a no-op.
There's also no need to initialise the
beacon_skb variable to NULL just after
the memory it is in has been kzalloc'ed.
Some minor whitespace cleanups, and a
lock assertion in a function that needs
the mutex (to access the beacon_skb var)
complete the patch.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Wey-Yi Guy <wey-yi.w.guy@intel.com>
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn.c | 25 |
1 files changed, 11 insertions, 14 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 0cc090b485a9..7079efbe34eb 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -314,9 +314,11 @@ static void iwl_free_frame(struct iwl_priv *priv, struct iwl_frame *frame) | |||
314 | } | 314 | } |
315 | 315 | ||
316 | static u32 iwl_fill_beacon_frame(struct iwl_priv *priv, | 316 | static u32 iwl_fill_beacon_frame(struct iwl_priv *priv, |
317 | struct ieee80211_hdr *hdr, | 317 | struct ieee80211_hdr *hdr, |
318 | int left) | 318 | int left) |
319 | { | 319 | { |
320 | lockdep_assert_held(&priv->mutex); | ||
321 | |||
320 | if (!priv->beacon_skb) | 322 | if (!priv->beacon_skb) |
321 | return 0; | 323 | return 0; |
322 | 324 | ||
@@ -330,8 +332,8 @@ static u32 iwl_fill_beacon_frame(struct iwl_priv *priv, | |||
330 | 332 | ||
331 | /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ | 333 | /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */ |
332 | static void iwl_set_beacon_tim(struct iwl_priv *priv, | 334 | static void iwl_set_beacon_tim(struct iwl_priv *priv, |
333 | struct iwl_tx_beacon_cmd *tx_beacon_cmd, | 335 | struct iwl_tx_beacon_cmd *tx_beacon_cmd, |
334 | u8 *beacon, u32 frame_size) | 336 | u8 *beacon, u32 frame_size) |
335 | { | 337 | { |
336 | u16 tim_idx; | 338 | u16 tim_idx; |
337 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; | 339 | struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon; |
@@ -393,7 +395,7 @@ static unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv, | |||
393 | 395 | ||
394 | /* Set up TX beacon command fields */ | 396 | /* Set up TX beacon command fields */ |
395 | iwl_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, | 397 | iwl_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame, |
396 | frame_size); | 398 | frame_size); |
397 | 399 | ||
398 | /* Set up packet rate and flags */ | 400 | /* Set up packet rate and flags */ |
399 | rate = iwl_rate_get_lowest_plcp(priv, priv->beacon_ctx); | 401 | rate = iwl_rate_get_lowest_plcp(priv, priv->beacon_ctx); |
@@ -648,13 +650,12 @@ static void iwl_bg_beacon_update(struct work_struct *work) | |||
648 | /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ | 650 | /* Pull updated AP beacon from mac80211. will fail if not in AP mode */ |
649 | beacon = ieee80211_beacon_get(priv->hw, priv->beacon_ctx->vif); | 651 | beacon = ieee80211_beacon_get(priv->hw, priv->beacon_ctx->vif); |
650 | if (!beacon) { | 652 | if (!beacon) { |
651 | IWL_ERR(priv, "update beacon failed\n"); | 653 | IWL_ERR(priv, "update beacon failed -- keeping old\n"); |
652 | goto out; | 654 | goto out; |
653 | } | 655 | } |
654 | 656 | ||
655 | /* new beacon skb is allocated every time; dispose previous.*/ | 657 | /* new beacon skb is allocated every time; dispose previous.*/ |
656 | if (priv->beacon_skb) | 658 | dev_kfree_skb(priv->beacon_skb); |
657 | dev_kfree_skb(priv->beacon_skb); | ||
658 | 659 | ||
659 | priv->beacon_skb = beacon; | 660 | priv->beacon_skb = beacon; |
660 | 661 | ||
@@ -2993,8 +2994,7 @@ static void __iwl_down(struct iwl_priv *priv) | |||
2993 | exit: | 2994 | exit: |
2994 | memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp)); | 2995 | memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp)); |
2995 | 2996 | ||
2996 | if (priv->beacon_skb) | 2997 | dev_kfree_skb(priv->beacon_skb); |
2997 | dev_kfree_skb(priv->beacon_skb); | ||
2998 | priv->beacon_skb = NULL; | 2998 | priv->beacon_skb = NULL; |
2999 | 2999 | ||
3000 | /* clear out any free frames */ | 3000 | /* clear out any free frames */ |
@@ -4131,8 +4131,6 @@ static int iwl_init_drv(struct iwl_priv *priv) | |||
4131 | { | 4131 | { |
4132 | int ret; | 4132 | int ret; |
4133 | 4133 | ||
4134 | priv->beacon_skb = NULL; | ||
4135 | |||
4136 | spin_lock_init(&priv->sta_lock); | 4134 | spin_lock_init(&priv->sta_lock); |
4137 | spin_lock_init(&priv->hcmd_lock); | 4135 | spin_lock_init(&priv->hcmd_lock); |
4138 | 4136 | ||
@@ -4645,8 +4643,7 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev) | |||
4645 | 4643 | ||
4646 | iwl_free_isr_ict(priv); | 4644 | iwl_free_isr_ict(priv); |
4647 | 4645 | ||
4648 | if (priv->beacon_skb) | 4646 | dev_kfree_skb(priv->beacon_skb); |
4649 | dev_kfree_skb(priv->beacon_skb); | ||
4650 | 4647 | ||
4651 | ieee80211_free_hw(priv->hw); | 4648 | ieee80211_free_hw(priv->hw); |
4652 | } | 4649 | } |