aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/mwifiex/cfp.c
diff options
context:
space:
mode:
authorYogesh Ashok Powar <yogeshp@marvell.com>2012-03-12 22:35:10 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-03-13 14:54:18 -0400
commit6685d109f4b60604fd206cff01355094a2e3b419 (patch)
treeaf19e8f14a9a1b98a0285a3433d74fff9c806d2a /drivers/net/wireless/mwifiex/cfp.c
parent985d68a3bb7678d6b4d5175f52d70b7f3abb992a (diff)
mwifiex: merge functions to derive cfp by chan & freq in one
There exist different functions with very long names to derive the channel frequency and power tripplet based on band and channel/freq. Signed-off-by: Yogesh Ashok Powar <yogeshp@marvell.com> Signed-off-by: Bing Zhao <bzhao@marvell.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/mwifiex/cfp.c')
-rw-r--r--drivers/net/wireless/mwifiex/cfp.c86
1 files changed, 30 insertions, 56 deletions
diff --git a/drivers/net/wireless/mwifiex/cfp.c b/drivers/net/wireless/mwifiex/cfp.c
index 1782a77f15dc..7541d9a4a6ed 100644
--- a/drivers/net/wireless/mwifiex/cfp.c
+++ b/drivers/net/wireless/mwifiex/cfp.c
@@ -169,59 +169,18 @@ u32 mwifiex_get_active_data_rates(struct mwifiex_private *priv, u8 *rates)
169 169
170/* 170/*
171 * This function locates the Channel-Frequency-Power triplet based upon 171 * This function locates the Channel-Frequency-Power triplet based upon
172 * band and channel parameters. 172 * band and channel/frequency parameters.
173 */ 173 */
174struct mwifiex_chan_freq_power * 174struct mwifiex_chan_freq_power *
175mwifiex_get_cfp_by_band_and_channel_from_cfg80211(struct mwifiex_private 175mwifiex_get_cfp(struct mwifiex_private *priv, u8 band, u16 channel, u32 freq)
176 *priv, u8 band, u16 channel)
177{ 176{
178 struct mwifiex_chan_freq_power *cfp = NULL; 177 struct mwifiex_chan_freq_power *cfp = NULL;
179 struct ieee80211_supported_band *sband; 178 struct ieee80211_supported_band *sband;
180 struct ieee80211_channel *ch; 179 struct ieee80211_channel *ch = NULL;
181 int i; 180 int i;
182 181
183 if (mwifiex_band_to_radio_type(band) == HostCmd_SCAN_RADIO_TYPE_BG) 182 if (!channel && !freq)
184 sband = priv->wdev->wiphy->bands[IEEE80211_BAND_2GHZ];
185 else
186 sband = priv->wdev->wiphy->bands[IEEE80211_BAND_5GHZ];
187
188 if (!sband) {
189 dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d"
190 " & channel %d\n", __func__, band, channel);
191 return cfp; 183 return cfp;
192 }
193
194 for (i = 0; i < sband->n_channels; i++) {
195 ch = &sband->channels[i];
196 if (((ch->hw_value == channel) ||
197 (channel == FIRST_VALID_CHANNEL))
198 && !(ch->flags & IEEE80211_CHAN_DISABLED)) {
199 priv->cfp.channel = channel;
200 priv->cfp.freq = ch->center_freq;
201 priv->cfp.max_tx_power = ch->max_power;
202 cfp = &priv->cfp;
203 break;
204 }
205 }
206 if (i == sband->n_channels)
207 dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d"
208 " & channel %d\n", __func__, band, channel);
209
210 return cfp;
211}
212
213/*
214 * This function locates the Channel-Frequency-Power triplet based upon
215 * band and frequency parameters.
216 */
217struct mwifiex_chan_freq_power *
218mwifiex_get_cfp_by_band_and_freq_from_cfg80211(struct mwifiex_private *priv,
219 u8 band, u32 freq)
220{
221 struct mwifiex_chan_freq_power *cfp = NULL;
222 struct ieee80211_supported_band *sband;
223 struct ieee80211_channel *ch;
224 int i;
225 184
226 if (mwifiex_band_to_radio_type(band) == HostCmd_SCAN_RADIO_TYPE_BG) 185 if (mwifiex_band_to_radio_type(band) == HostCmd_SCAN_RADIO_TYPE_BG)
227 sband = priv->wdev->wiphy->bands[IEEE80211_BAND_2GHZ]; 186 sband = priv->wdev->wiphy->bands[IEEE80211_BAND_2GHZ];
@@ -229,25 +188,40 @@ mwifiex_get_cfp_by_band_and_freq_from_cfg80211(struct mwifiex_private *priv,
229 sband = priv->wdev->wiphy->bands[IEEE80211_BAND_5GHZ]; 188 sband = priv->wdev->wiphy->bands[IEEE80211_BAND_5GHZ];
230 189
231 if (!sband) { 190 if (!sband) {
232 dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d" 191 dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d\n",
233 " & freq %d\n", __func__, band, freq); 192 __func__, band);
234 return cfp; 193 return cfp;
235 } 194 }
236 195
237 for (i = 0; i < sband->n_channels; i++) { 196 for (i = 0; i < sband->n_channels; i++) {
238 ch = &sband->channels[i]; 197 ch = &sband->channels[i];
239 if ((ch->center_freq == freq) && 198
240 !(ch->flags & IEEE80211_CHAN_DISABLED)) { 199 if (ch->flags & IEEE80211_CHAN_DISABLED)
241 priv->cfp.channel = ch->hw_value; 200 continue;
242 priv->cfp.freq = freq; 201
243 priv->cfp.max_tx_power = ch->max_power; 202 if (freq) {
244 cfp = &priv->cfp; 203 if (ch->center_freq == freq)
245 break; 204 break;
205 } else {
206 /* find by valid channel*/
207 if (ch->hw_value == channel ||
208 channel == FIRST_VALID_CHANNEL)
209 break;
246 } 210 }
247 } 211 }
248 if (i == sband->n_channels) 212 if (i == sband->n_channels) {
249 dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d" 213 dev_err(priv->adapter->dev, "%s: cannot find cfp by band %d"
250 " & freq %d\n", __func__, band, freq); 214 " & channel=%d freq=%d\n", __func__, band, channel,
215 freq);
216 } else {
217 if (!ch)
218 return cfp;
219
220 priv->cfp.channel = ch->hw_value;
221 priv->cfp.freq = ch->center_freq;
222 priv->cfp.max_tx_power = ch->max_power;
223 cfp = &priv->cfp;
224 }
251 225
252 return cfp; 226 return cfp;
253} 227}