diff options
author | Johannes Berg <johannes.berg@intel.com> | 2010-04-30 17:08:00 -0400 |
---|---|---|
committer | Reinette Chatre <reinette.chatre@intel.com> | 2010-05-13 13:42:32 -0400 |
commit | 0af8bcae6f44aa440e51b1925635fb835cd68058 (patch) | |
tree | 99256de08f84d6b2e6db87ec32b3471ed5bb3b89 /drivers/net | |
parent | fd76f148ebc67d662f71f00128c8ddb0538168c0 (diff) |
iwlwifi: introduce iwl_sta_id_or_broadcast
There are now five places where we need to
look up the station ID, but the sta pointer
may be NULL due to mac80211 passing that to
indicate a certain special state.
Replace all these by a new inline function,
called iwl_sta_id_or_broadcast(), and add
documentation about when to use it.
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Reinette Chatre <reinette.chatre@intel.com>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn-tx.c | 5 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-agn.c | 14 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-sta.c | 16 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl-sta.h | 29 | ||||
-rw-r--r-- | drivers/net/wireless/iwlwifi/iwl3945-base.c | 19 |
5 files changed, 41 insertions, 42 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c index c402bfc83f36..18b15466fce1 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn-tx.c | |||
@@ -567,10 +567,7 @@ int iwlagn_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | |||
567 | hdr_len = ieee80211_hdrlen(fc); | 567 | hdr_len = ieee80211_hdrlen(fc); |
568 | 568 | ||
569 | /* Find index into station table for destination station */ | 569 | /* Find index into station table for destination station */ |
570 | if (!info->control.sta) | 570 | sta_id = iwl_sta_id_or_broadcast(priv, info->control.sta); |
571 | sta_id = priv->hw_params.bcast_sta_id; | ||
572 | else | ||
573 | sta_id = iwl_sta_id(info->control.sta); | ||
574 | if (sta_id == IWL_INVALID_STATION) { | 571 | if (sta_id == IWL_INVALID_STATION) { |
575 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | 572 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", |
576 | hdr->addr1); | 573 | hdr->addr1); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 47563cf9cbaa..d7a9aea6cdaa 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -3081,17 +3081,9 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
3081 | return -EOPNOTSUPP; | 3081 | return -EOPNOTSUPP; |
3082 | } | 3082 | } |
3083 | 3083 | ||
3084 | if (sta) { | 3084 | sta_id = iwl_sta_id_or_broadcast(priv, sta); |
3085 | sta_id = iwl_sta_id(sta); | 3085 | if (sta_id == IWL_INVALID_STATION) |
3086 | 3086 | return -EINVAL; | |
3087 | if (sta_id == IWL_INVALID_STATION) { | ||
3088 | IWL_DEBUG_MAC80211(priv, "leave - %pM not in station map.\n", | ||
3089 | sta->addr); | ||
3090 | return -EINVAL; | ||
3091 | } | ||
3092 | } else { | ||
3093 | sta_id = priv->hw_params.bcast_sta_id; | ||
3094 | } | ||
3095 | 3087 | ||
3096 | mutex_lock(&priv->mutex); | 3088 | mutex_lock(&priv->mutex); |
3097 | iwl_scan_cancel_timeout(priv, 100); | 3089 | iwl_scan_cancel_timeout(priv, 100); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.c b/drivers/net/wireless/iwlwifi/iwl-sta.c index 85ed235ac901..2eafba60053b 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.c +++ b/drivers/net/wireless/iwlwifi/iwl-sta.c | |||
@@ -972,24 +972,16 @@ void iwl_update_tkip_key(struct iwl_priv *priv, | |||
972 | unsigned long flags; | 972 | unsigned long flags; |
973 | int i; | 973 | int i; |
974 | 974 | ||
975 | if (sta) { | ||
976 | sta_id = iwl_sta_id(sta); | ||
977 | |||
978 | if (sta_id == IWL_INVALID_STATION) { | ||
979 | IWL_DEBUG_MAC80211(priv, "leave - %pM not initialised.\n", | ||
980 | sta->addr); | ||
981 | return; | ||
982 | } | ||
983 | } else | ||
984 | sta_id = priv->hw_params.bcast_sta_id; | ||
985 | |||
986 | |||
987 | if (iwl_scan_cancel(priv)) { | 975 | if (iwl_scan_cancel(priv)) { |
988 | /* cancel scan failed, just live w/ bad key and rely | 976 | /* cancel scan failed, just live w/ bad key and rely |
989 | briefly on SW decryption */ | 977 | briefly on SW decryption */ |
990 | return; | 978 | return; |
991 | } | 979 | } |
992 | 980 | ||
981 | sta_id = iwl_sta_id_or_broadcast(priv, sta); | ||
982 | if (sta_id == IWL_INVALID_STATION) | ||
983 | return; | ||
984 | |||
993 | spin_lock_irqsave(&priv->sta_lock, flags); | 985 | spin_lock_irqsave(&priv->sta_lock, flags); |
994 | 986 | ||
995 | priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; | 987 | priv->stations[sta_id].sta.key.tkip_rx_tsc_byte2 = (u8) iv32; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-sta.h b/drivers/net/wireless/iwlwifi/iwl-sta.h index c2a453a1a991..5b1b1e461eb6 100644 --- a/drivers/net/wireless/iwlwifi/iwl-sta.h +++ b/drivers/net/wireless/iwlwifi/iwl-sta.h | |||
@@ -107,4 +107,33 @@ static inline int iwl_sta_id(struct ieee80211_sta *sta) | |||
107 | 107 | ||
108 | return ((struct iwl_station_priv_common *)sta->drv_priv)->sta_id; | 108 | return ((struct iwl_station_priv_common *)sta->drv_priv)->sta_id; |
109 | } | 109 | } |
110 | |||
111 | /** | ||
112 | * iwl_sta_id_or_broadcast - return sta_id or broadcast sta | ||
113 | * @priv: iwl priv | ||
114 | * @sta: mac80211 station | ||
115 | * | ||
116 | * In certain circumstances mac80211 passes a station pointer | ||
117 | * that may be %NULL, for example during TX or key setup. In | ||
118 | * that case, we need to use the broadcast station, so this | ||
119 | * inline wraps that pattern. | ||
120 | */ | ||
121 | static inline int iwl_sta_id_or_broadcast(struct iwl_priv *priv, | ||
122 | struct ieee80211_sta *sta) | ||
123 | { | ||
124 | int sta_id; | ||
125 | |||
126 | if (!sta) | ||
127 | return priv->hw_params.bcast_sta_id; | ||
128 | |||
129 | sta_id = iwl_sta_id(sta); | ||
130 | |||
131 | /* | ||
132 | * mac80211 should not be passing a partially | ||
133 | * initialised station! | ||
134 | */ | ||
135 | WARN_ON(sta_id == IWL_INVALID_STATION); | ||
136 | |||
137 | return sta_id; | ||
138 | } | ||
110 | #endif /* __iwl_sta_h__ */ | 139 | #endif /* __iwl_sta_h__ */ |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index 4c78783a6035..68b8a1af3be7 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -509,10 +509,7 @@ static int iwl3945_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | |||
509 | hdr_len = ieee80211_hdrlen(fc); | 509 | hdr_len = ieee80211_hdrlen(fc); |
510 | 510 | ||
511 | /* Find index into station table for destination station */ | 511 | /* Find index into station table for destination station */ |
512 | if (!info->control.sta) | 512 | sta_id = iwl_sta_id_or_broadcast(priv, info->control.sta); |
513 | sta_id = priv->hw_params.bcast_sta_id; | ||
514 | else | ||
515 | sta_id = iwl_sta_id(info->control.sta); | ||
516 | if (sta_id == IWL_INVALID_STATION) { | 513 | if (sta_id == IWL_INVALID_STATION) { |
517 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", | 514 | IWL_DEBUG_DROP(priv, "Dropping - INVALID STATION: %pM\n", |
518 | hdr->addr1); | 515 | hdr->addr1); |
@@ -3336,17 +3333,9 @@ static int iwl3945_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
3336 | static_key = !iwl_is_associated(priv); | 3333 | static_key = !iwl_is_associated(priv); |
3337 | 3334 | ||
3338 | if (!static_key) { | 3335 | if (!static_key) { |
3339 | if (!sta) { | 3336 | sta_id = iwl_sta_id_or_broadcast(priv, sta); |
3340 | sta_id = priv->hw_params.bcast_sta_id; | 3337 | if (sta_id == IWL_INVALID_STATION) |
3341 | } else { | 3338 | return -EINVAL; |
3342 | sta_id = iwl_sta_id(sta); | ||
3343 | if (sta_id == IWL_INVALID_STATION) { | ||
3344 | IWL_DEBUG_MAC80211(priv, | ||
3345 | "leave - %pM not in station map.\n", | ||
3346 | sta->addr); | ||
3347 | return -EINVAL; | ||
3348 | } | ||
3349 | } | ||
3350 | } | 3339 | } |
3351 | 3340 | ||
3352 | mutex_lock(&priv->mutex); | 3341 | mutex_lock(&priv->mutex); |