linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Wey-Yi Guy <wey-yi.w.guy@intel.com>
To: linville@tuxdriver.com
Cc: linux-wireless@vger.kernel.org,
	ipw3945-devel@lists.sourceforge.net,
	Johannes Berg <johannes.berg@intel.com>,
	Wey-Yi Guy <wey-yi.w.guy@intel.com>
Subject: [PATCH 4/9] iwlwifi: clean up some beacon handling
Date: Thu, 14 Oct 2010 11:02:45 -0700	[thread overview]
Message-ID: <1287079370-20587-5-git-send-email-wey-yi.w.guy@intel.com> (raw)
In-Reply-To: <1287079370-20587-1-git-send-email-wey-yi.w.guy@intel.com>

From: Johannes Berg <johannes.berg@intel.com>

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>
---
 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 0cc090b..7079efb 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)
 }
 
 static u32 iwl_fill_beacon_frame(struct iwl_priv *priv,
-					  struct ieee80211_hdr *hdr,
-					  int left)
+				 struct ieee80211_hdr *hdr,
+				 int left)
 {
+	lockdep_assert_held(&priv->mutex);
+
 	if (!priv->beacon_skb)
 		return 0;
 
@@ -330,8 +332,8 @@ static u32 iwl_fill_beacon_frame(struct iwl_priv *priv,
 
 /* Parse the beacon frame to find the TIM element and set tim_idx & tim_size */
 static void iwl_set_beacon_tim(struct iwl_priv *priv,
-		struct iwl_tx_beacon_cmd *tx_beacon_cmd,
-		u8 *beacon, u32 frame_size)
+			       struct iwl_tx_beacon_cmd *tx_beacon_cmd,
+			       u8 *beacon, u32 frame_size)
 {
 	u16 tim_idx;
 	struct ieee80211_mgmt *mgmt = (struct ieee80211_mgmt *)beacon;
@@ -393,7 +395,7 @@ static unsigned int iwl_hw_get_beacon_cmd(struct iwl_priv *priv,
 
 	/* Set up TX beacon command fields */
 	iwl_set_beacon_tim(priv, tx_beacon_cmd, (u8 *)tx_beacon_cmd->frame,
-			frame_size);
+			   frame_size);
 
 	/* Set up packet rate and flags */
 	rate = iwl_rate_get_lowest_plcp(priv, priv->beacon_ctx);
@@ -648,13 +650,12 @@ static void iwl_bg_beacon_update(struct work_struct *work)
 	/* Pull updated AP beacon from mac80211. will fail if not in AP mode */
 	beacon = ieee80211_beacon_get(priv->hw, priv->beacon_ctx->vif);
 	if (!beacon) {
-		IWL_ERR(priv, "update beacon failed\n");
+		IWL_ERR(priv, "update beacon failed -- keeping old\n");
 		goto out;
 	}
 
 	/* new beacon skb is allocated every time; dispose previous.*/
-	if (priv->beacon_skb)
-		dev_kfree_skb(priv->beacon_skb);
+	dev_kfree_skb(priv->beacon_skb);
 
 	priv->beacon_skb = beacon;
 
@@ -2993,8 +2994,7 @@ static void __iwl_down(struct iwl_priv *priv)
  exit:
 	memset(&priv->card_alive, 0, sizeof(struct iwl_alive_resp));
 
-	if (priv->beacon_skb)
-		dev_kfree_skb(priv->beacon_skb);
+	dev_kfree_skb(priv->beacon_skb);
 	priv->beacon_skb = NULL;
 
 	/* clear out any free frames */
@@ -4131,8 +4131,6 @@ static int iwl_init_drv(struct iwl_priv *priv)
 {
 	int ret;
 
-	priv->beacon_skb = NULL;
-
 	spin_lock_init(&priv->sta_lock);
 	spin_lock_init(&priv->hcmd_lock);
 
@@ -4645,8 +4643,7 @@ static void __devexit iwl_pci_remove(struct pci_dev *pdev)
 
 	iwl_free_isr_ict(priv);
 
-	if (priv->beacon_skb)
-		dev_kfree_skb(priv->beacon_skb);
+	dev_kfree_skb(priv->beacon_skb);
 
 	ieee80211_free_hw(priv->hw);
 }
-- 
1.7.0.4


  parent reply	other threads:[~2010-10-14 18:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-14 18:02 [PATCH 0/9] update for 2.6.37 Wey-Yi Guy
2010-10-14 18:02 ` [PATCH 1/9] iwlagn: need longer tx queue stuck timer for coex devices Wey-Yi Guy
2010-10-15 16:44   ` Stanislaw Gruszka
2010-10-15 18:01     ` Guy, Wey-Yi W
2010-10-18 12:12       ` Stanislaw Gruszka
2010-10-18 14:16         ` Guy, Wey-Yi
2010-10-14 18:02 ` [PATCH 2/9] iwlwifi: allow probe-after-rx on 2.4 GHz Wey-Yi Guy
2010-10-14 18:02 ` [PATCH 3/9] iwlwifi: rename ibss_beacon variable Wey-Yi Guy
2010-10-14 18:02 ` Wey-Yi Guy [this message]
2010-10-14 18:02 ` [PATCH 5/9] iwlagn: 6050 ops should be used; Wey-Yi Guy
2010-10-14 18:02 ` [PATCH 6/9] iwlwifi: rewrite RXON checks Wey-Yi Guy
2010-10-14 18:02 ` [PATCH 7/9] iwlwifi: blink LED in IBSS mode Wey-Yi Guy
2010-10-14 18:02 ` [PATCH 8/9] iwlagn: check beacon frame size Wey-Yi Guy
2010-10-14 18:02 ` [PATCH 9/9] iwlwifi: move agn only eeprom functions to separate file Wey-Yi Guy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1287079370-20587-5-git-send-email-wey-yi.w.guy@intel.com \
    --to=wey-yi.w.guy@intel.com \
    --cc=ipw3945-devel@lists.sourceforge.net \
    --cc=johannes.berg@intel.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=linville@tuxdriver.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).