aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/iwlwifi/iwl-sta.h
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2010-04-30 17:08:00 -0400
committerReinette Chatre <reinette.chatre@intel.com>2010-05-13 13:42:32 -0400
commit0af8bcae6f44aa440e51b1925635fb835cd68058 (patch)
tree99256de08f84d6b2e6db87ec32b3471ed5bb3b89 /drivers/net/wireless/iwlwifi/iwl-sta.h
parentfd76f148ebc67d662f71f00128c8ddb0538168c0 (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/wireless/iwlwifi/iwl-sta.h')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-sta.h29
1 files changed, 29 insertions, 0 deletions
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 */
121static 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__ */