aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStanislaw Gruszka <sgruszka@redhat.com>2011-08-26 04:45:16 -0400
committerStanislaw Gruszka <sgruszka@redhat.com>2011-11-15 05:23:08 -0500
commit232913b51e6f6e7105184b23a436dfc6b942491b (patch)
tree7411b528ab8e501ce3ab3e3f903d60ea98c7a14f
parentdb54eb57ce5edeebd621b12e23f3e1cdea7fe3ee (diff)
iwlegacy: remove not needed parentheses
Signed-off-by: Stanislaw Gruszka <sgruszka@redhat.com>
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945-hw.h4
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945-rs.c40
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-3945.c25
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-calib.c27
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-hw.h8
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-lib.c6
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-rs.c125
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965-tx.c19
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965.c44
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-4965.h4
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-core.c18
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-io.h2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-legacy-rs.h2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-scan.c2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-sta.c2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl-tx.c2
-rw-r--r--drivers/net/wireless/iwlegacy/iwl3945-base.c20
17 files changed, 168 insertions, 182 deletions
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h
index ad050937871..67650ffa2d5 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945-hw.h
+++ b/drivers/net/wireless/iwlegacy/iwl-3945-hw.h
@@ -264,8 +264,8 @@ struct il3945_eeprom {
264 264
265static inline int il3945_hw_valid_rtc_data_addr(u32 addr) 265static inline int il3945_hw_valid_rtc_data_addr(u32 addr)
266{ 266{
267 return (addr >= IWL39_RTC_DATA_LOWER_BOUND) && 267 return (addr >= IWL39_RTC_DATA_LOWER_BOUND &&
268 (addr < IWL39_RTC_DATA_UPPER_BOUND); 268 addr < IWL39_RTC_DATA_UPPER_BOUND);
269} 269}
270 270
271/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE 271/* Base physical address of il3945_shared is provided to FH_TSSR_CBB_BASE
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
index d05da7a46c4..afa6be81f9a 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945-rs.c
@@ -104,7 +104,7 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band)
104 u32 table_size = 0; 104 u32 table_size = 0;
105 struct il3945_tpt_entry *tpt_table = NULL; 105 struct il3945_tpt_entry *tpt_table = NULL;
106 106
107 if ((rssi < IL_MIN_RSSI_VAL) || (rssi > IL_MAX_RSSI_VAL)) 107 if (rssi < IL_MIN_RSSI_VAL || rssi > IL_MAX_RSSI_VAL)
108 rssi = IL_MIN_RSSI_VAL; 108 rssi = IL_MIN_RSSI_VAL;
109 109
110 switch (band) { 110 switch (band) {
@@ -123,7 +123,7 @@ static u8 il3945_get_rate_index_by_rssi(s32 rssi, enum ieee80211_band band)
123 break; 123 break;
124 } 124 }
125 125
126 while ((index < table_size) && (rssi < tpt_table[index].min_rssi)) 126 while (index < table_size && rssi < tpt_table[index].min_rssi)
127 index++; 127 index++;
128 128
129 index = min(index, (table_size - 1)); 129 index = min(index, (table_size - 1));
@@ -315,8 +315,8 @@ static void il3945_collect_tx_data(struct il3945_rs_sta *rs_sta,
315 fail_count = window->counter - window->success_counter; 315 fail_count = window->counter - window->success_counter;
316 316
317 /* Calculate average throughput, if we have enough history. */ 317 /* Calculate average throughput, if we have enough history. */
318 if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || 318 if (fail_count >= IL_RATE_MIN_FAILURE_TH ||
319 (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) 319 window->success_counter >= IL_RATE_MIN_SUCCESS_TH)
320 window->average_tpt = ((window->success_ratio * 320 window->average_tpt = ((window->success_ratio *
321 rs_sta->expected_tpt[index] + 64) / 128); 321 rs_sta->expected_tpt[index] + 64) / 128);
322 else 322 else
@@ -461,7 +461,7 @@ static void il3945_rs_tx_status(void *il_rate, struct ieee80211_supported_band *
461 retries = IL_RATE_RETRY_TH; 461 retries = IL_RATE_RETRY_TH;
462 462
463 first_index = sband->bitrates[info->status.rates[0].idx].hw_value; 463 first_index = sband->bitrates[info->status.rates[0].idx].hw_value;
464 if ((first_index < 0) || (first_index >= IL_RATE_COUNT_3945)) { 464 if (first_index < 0 || first_index >= IL_RATE_COUNT_3945) {
465 D_RATE("leave: Rate out of bounds: %d\n", first_index); 465 D_RATE("leave: Rate out of bounds: %d\n", first_index);
466 return; 466 return;
467 } 467 }
@@ -663,9 +663,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
663 663
664 /* get user max rate if set */ 664 /* get user max rate if set */
665 max_rate_idx = txrc->max_rate_idx; 665 max_rate_idx = txrc->max_rate_idx;
666 if ((sband->band == IEEE80211_BAND_5GHZ) && (max_rate_idx != -1)) 666 if (sband->band == IEEE80211_BAND_5GHZ && max_rate_idx != -1)
667 max_rate_idx += IL_FIRST_OFDM_RATE; 667 max_rate_idx += IL_FIRST_OFDM_RATE;
668 if ((max_rate_idx < 0) || (max_rate_idx >= IL_RATE_COUNT)) 668 if (max_rate_idx < 0 || max_rate_idx >= IL_RATE_COUNT)
669 max_rate_idx = -1; 669 max_rate_idx = -1;
670 670
671 index = min(rs_sta->last_txrate_idx & 0xffff, IL_RATE_COUNT_3945 - 1); 671 index = min(rs_sta->last_txrate_idx & 0xffff, IL_RATE_COUNT_3945 - 1);
@@ -686,7 +686,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
686 } 686 }
687 687
688 /* force user max rate if set by user */ 688 /* force user max rate if set by user */
689 if ((max_rate_idx != -1) && (max_rate_idx < index)) { 689 if (max_rate_idx != -1 && max_rate_idx < index) {
690 if (rate_mask & (1 << max_rate_idx)) 690 if (rate_mask & (1 << max_rate_idx))
691 index = max_rate_idx; 691 index = max_rate_idx;
692 } 692 }
@@ -695,8 +695,8 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
695 695
696 fail_count = window->counter - window->success_counter; 696 fail_count = window->counter - window->success_counter;
697 697
698 if (((fail_count < IL_RATE_MIN_FAILURE_TH) && 698 if (fail_count < IL_RATE_MIN_FAILURE_TH &&
699 (window->success_counter < IL_RATE_MIN_SUCCESS_TH))) { 699 window->success_counter < IL_RATE_MIN_SUCCESS_TH) {
700 spin_unlock_irqrestore(&rs_sta->lock, flags); 700 spin_unlock_irqrestore(&rs_sta->lock, flags);
701 701
702 D_RATE("Invalid average_tpt on rate %d: " 702 D_RATE("Invalid average_tpt on rate %d: "
@@ -721,7 +721,7 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
721 high = (high_low >> 8) & 0xff; 721 high = (high_low >> 8) & 0xff;
722 722
723 /* If user set max rate, dont allow higher than user constrain */ 723 /* If user set max rate, dont allow higher than user constrain */
724 if ((max_rate_idx != -1) && (max_rate_idx < high)) 724 if (max_rate_idx != -1 && max_rate_idx < high)
725 high = IL_RATE_INVALID; 725 high = IL_RATE_INVALID;
726 726
727 /* Collect Measured throughputs of adjacent rates */ 727 /* Collect Measured throughputs of adjacent rates */
@@ -736,13 +736,13 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
736 scale_action = 0; 736 scale_action = 0;
737 737
738 /* Low success ratio , need to drop the rate */ 738 /* Low success ratio , need to drop the rate */
739 if ((window->success_ratio < IL_RATE_DECREASE_TH) || !current_tpt) { 739 if (window->success_ratio < IL_RATE_DECREASE_TH || !current_tpt) {
740 D_RATE("decrease rate because of low success_ratio\n"); 740 D_RATE("decrease rate because of low success_ratio\n");
741 scale_action = -1; 741 scale_action = -1;
742 /* No throughput measured yet for adjacent rates, 742 /* No throughput measured yet for adjacent rates,
743 * try increase */ 743 * try increase */
744 } else if ((low_tpt == IL_INVALID_VALUE) && 744 } else if (low_tpt == IL_INVALID_VALUE &&
745 (high_tpt == IL_INVALID_VALUE)) { 745 high_tpt == IL_INVALID_VALUE) {
746 746
747 if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH) 747 if (high != IL_RATE_INVALID && window->success_ratio >= IL_RATE_INCREASE_TH)
748 scale_action = 1; 748 scale_action = 1;
@@ -752,9 +752,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
752 /* Both adjacent throughputs are measured, but neither one has 752 /* Both adjacent throughputs are measured, but neither one has
753 * better throughput; we're using the best rate, don't change 753 * better throughput; we're using the best rate, don't change
754 * it! */ 754 * it! */
755 } else if ((low_tpt != IL_INVALID_VALUE) && 755 } else if (low_tpt != IL_INVALID_VALUE &&
756 (high_tpt != IL_INVALID_VALUE) && 756 high_tpt != IL_INVALID_VALUE &&
757 (low_tpt < current_tpt) && (high_tpt < current_tpt)) { 757 low_tpt < current_tpt && high_tpt < current_tpt) {
758 758
759 D_RATE("No action -- low [%d] & high [%d] < " 759 D_RATE("No action -- low [%d] & high [%d] < "
760 "current_tpt [%d]\n", 760 "current_tpt [%d]\n",
@@ -790,9 +790,9 @@ static void il3945_rs_get_rate(void *il_r, struct ieee80211_sta *sta,
790 790
791 /* Sanity check; asked for decrease, but success rate or throughput 791 /* Sanity check; asked for decrease, but success rate or throughput
792 * has been good at old rate. Don't change it. */ 792 * has been good at old rate. Don't change it. */
793 if ((scale_action == -1) && (low != IL_RATE_INVALID) && 793 if (scale_action == -1 && low != IL_RATE_INVALID &&
794 ((window->success_ratio > IL_RATE_HIGH_TH) || 794 (window->success_ratio > IL_RATE_HIGH_TH ||
795 (current_tpt > (100 * rs_sta->expected_tpt[low])))) 795 current_tpt > 100 * rs_sta->expected_tpt[low]))
796 scale_action = 0; 796 scale_action = 0;
797 797
798 switch (scale_action) { 798 switch (scale_action) {
diff --git a/drivers/net/wireless/iwlegacy/iwl-3945.c b/drivers/net/wireless/iwlegacy/iwl-3945.c
index cdea5b03648..fb69b745f8a 100644
--- a/drivers/net/wireless/iwlegacy/iwl-3945.c
+++ b/drivers/net/wireless/iwlegacy/iwl-3945.c
@@ -173,7 +173,7 @@ void il3945_disable_events(struct il_priv *il)
173 disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32))); 173 disable_ptr = il_read_targ_mem(il, base + (4 * sizeof(u32)));
174 array_size = il_read_targ_mem(il, base + (5 * sizeof(u32))); 174 array_size = il_read_targ_mem(il, base + (5 * sizeof(u32)));
175 175
176 if (IL_EVT_DISABLE && (array_size == IL_EVT_DISABLE_SIZE)) { 176 if (IL_EVT_DISABLE && array_size == IL_EVT_DISABLE_SIZE) {
177 D_INFO("Disabling selected uCode log events at 0x%x\n", 177 D_INFO("Disabling selected uCode log events at 0x%x\n",
178 disable_ptr); 178 disable_ptr);
179 for (i = 0; i < IL_EVT_DISABLE_SIZE; i++) 179 for (i = 0; i < IL_EVT_DISABLE_SIZE; i++)
@@ -293,9 +293,8 @@ static void il3945_tx_queue_reclaim(struct il_priv *il,
293 il->cfg->ops->lib->txq_free_tfd(il, txq); 293 il->cfg->ops->lib->txq_free_tfd(il, txq);
294 } 294 }
295 295
296 if (il_queue_space(q) > q->low_mark && (txq_id >= 0) && 296 if (il_queue_space(q) > q->low_mark && txq_id >= 0 &&
297 (txq_id != IWL39_CMD_QUEUE_NUM) && 297 txq_id != IWL39_CMD_QUEUE_NUM && il->mac80211_registered)
298 il->mac80211_registered)
299 il_wake_queue(il, txq); 298 il_wake_queue(il, txq);
300} 299}
301 300
@@ -316,7 +315,7 @@ static void il3945_rx_reply_tx(struct il_priv *il,
316 int rate_idx; 315 int rate_idx;
317 int fail; 316 int fail;
318 317
319 if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { 318 if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) {
320 IL_ERR("Read index for DMA queue txq_id (%d) index %d " 319 IL_ERR("Read index for DMA queue txq_id (%d) index %d "
321 "is out of range [0-%d] %d %d\n", txq_id, 320 "is out of range [0-%d] %d %d\n", txq_id,
322 index, txq->q.n_bd, txq->q.write_ptr, 321 index, txq->q.n_bd, txq->q.write_ptr,
@@ -544,8 +543,8 @@ static void il3945_rx_reply_rx(struct il_priv *il,
544 return; 543 return;
545 } 544 }
546 545
547 if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) 546 if (!(rx_end->status & RX_RES_STATUS_NO_CRC32_ERROR) ||
548 || !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) { 547 !(rx_end->status & RX_RES_STATUS_NO_RXE_OVERFLOW)) {
549 D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status); 548 D_RX("Bad CRC or FIFO: 0x%08X.\n", rx_end->status);
550 return; 549 return;
551 } 550 }
@@ -599,7 +598,7 @@ int il3945_hw_txq_attach_buf_to_tfd(struct il_priv *il,
599 598
600 count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags)); 599 count = TFD_CTL_COUNT_GET(le32_to_cpu(tfd->control_flags));
601 600
602 if ((count >= NUM_TFD_CHUNKS) || (count < 0)) { 601 if (count >= NUM_TFD_CHUNKS || count < 0) {
603 IL_ERR("Error can not send more than %d chunks\n", 602 IL_ERR("Error can not send more than %d chunks\n",
604 NUM_TFD_CHUNKS); 603 NUM_TFD_CHUNKS);
605 return -EINVAL; 604 return -EINVAL;
@@ -1053,7 +1052,7 @@ static int il3945_hw_reg_adjust_power_by_temp(int new_reading, int old_reading)
1053 */ 1052 */
1054static inline int il3945_hw_reg_temp_out_of_range(int temperature) 1053static inline int il3945_hw_reg_temp_out_of_range(int temperature)
1055{ 1054{
1056 return ((temperature < -260) || (temperature > 25)) ? 1 : 0; 1055 return (temperature < -260 || temperature > 25) ? 1 : 0;
1057} 1056}
1058 1057
1059int il3945_hw_get_temperature(struct il_priv *il) 1058int il3945_hw_get_temperature(struct il_priv *il)
@@ -1666,10 +1665,10 @@ static int il3945_send_rxon_assoc(struct il_priv *il,
1666 const struct il_rxon_cmd *rxon1 = &ctx->staging; 1665 const struct il_rxon_cmd *rxon1 = &ctx->staging;
1667 const struct il_rxon_cmd *rxon2 = &ctx->active; 1666 const struct il_rxon_cmd *rxon2 = &ctx->active;
1668 1667
1669 if ((rxon1->flags == rxon2->flags) && 1668 if (rxon1->flags == rxon2->flags &&
1670 (rxon1->filter_flags == rxon2->filter_flags) && 1669 rxon1->filter_flags == rxon2->filter_flags &&
1671 (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && 1670 rxon1->cck_basic_rates == rxon2->cck_basic_rates &&
1672 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { 1671 rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) {
1673 D_INFO("Using current RXON_ASSOC. Not resending.\n"); 1672 D_INFO("Using current RXON_ASSOC. Not resending.\n");
1674 return 0; 1673 return 0;
1675 } 1674 }
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
index 7f858344b92..c055a153f7d 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-calib.c
@@ -198,8 +198,8 @@ static int il4965_sens_energy_cck(struct il_priv *il,
198 data->num_in_cck_no_fa); 198 data->num_in_cck_no_fa);
199 199
200 /* If we got too many false alarms this time, reduce sensitivity */ 200 /* If we got too many false alarms this time, reduce sensitivity */
201 if ((false_alarms > max_false_alarms) && 201 if (false_alarms > max_false_alarms &&
202 (data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK)) { 202 data->auto_corr_cck > AUTO_CORR_MAX_TH_CCK) {
203 D_CALIB("norm FA %u > max FA %u\n", 203 D_CALIB("norm FA %u > max FA %u\n",
204 false_alarms, max_false_alarms); 204 false_alarms, max_false_alarms);
205 D_CALIB("... reducing sensitivity\n"); 205 D_CALIB("... reducing sensitivity\n");
@@ -230,9 +230,9 @@ static int il4965_sens_energy_cck(struct il_priv *il,
230 * from a previous beacon with too many, or healthy # FAs 230 * from a previous beacon with too many, or healthy # FAs
231 * OR 2) We've seen a lot of beacons (100) with too few 231 * OR 2) We've seen a lot of beacons (100) with too few
232 * false alarms */ 232 * false alarms */
233 if ((data->nrg_prev_state != IL_FA_TOO_MANY) && 233 if (data->nrg_prev_state != IL_FA_TOO_MANY &&
234 ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || 234 (data->nrg_auto_corr_silence_diff > NRG_DIFF ||
235 (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { 235 data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) {
236 236
237 D_CALIB("... increasing sensitivity\n"); 237 D_CALIB("... increasing sensitivity\n");
238 /* Increase nrg value to increase sensitivity */ 238 /* Increase nrg value to increase sensitivity */
@@ -289,9 +289,9 @@ static int il4965_sens_energy_cck(struct il_priv *il,
289 val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK; 289 val = data->auto_corr_cck_mrc + AUTO_CORR_STEP_CCK;
290 data->auto_corr_cck_mrc = 290 data->auto_corr_cck_mrc =
291 min((u32)ranges->auto_corr_max_cck_mrc, val); 291 min((u32)ranges->auto_corr_max_cck_mrc, val);
292 } else if ((false_alarms < min_false_alarms) && 292 } else if (false_alarms < min_false_alarms &&
293 ((data->nrg_auto_corr_silence_diff > NRG_DIFF) || 293 (data->nrg_auto_corr_silence_diff > NRG_DIFF ||
294 (data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA))) { 294 data->num_in_cck_no_fa > MAX_NUMBER_CCK_NO_FA)) {
295 295
296 /* Decrease auto_corr values to increase sensitivity */ 296 /* Decrease auto_corr values to increase sensitivity */
297 val = data->auto_corr_cck - AUTO_CORR_STEP_CCK; 297 val = data->auto_corr_cck - AUTO_CORR_STEP_CCK;
@@ -747,9 +747,8 @@ static void il4965_gain_computation(struct il_priv *il,
747 for (i = default_chain; i < NUM_RX_CHAINS; i++) { 747 for (i = default_chain; i < NUM_RX_CHAINS; i++) {
748 s32 delta_g = 0; 748 s32 delta_g = 0;
749 749
750 if (!(data->disconn_array[i]) && 750 if (!data->disconn_array[i] &&
751 (data->delta_gain_code[i] == 751 data->delta_gain_code[i] == CHAIN_NOISE_DELTA_GAIN_INIT_VAL) {
752 CHAIN_NOISE_DELTA_GAIN_INIT_VAL)) {
753 delta_g = average_noise[i] - min_average_noise; 752 delta_g = average_noise[i] - min_average_noise;
754 data->delta_gain_code[i] = (u8)((delta_g * 10) / 15); 753 data->delta_gain_code[i] = (u8)((delta_g * 10) / 15);
755 data->delta_gain_code[i] = 754 data->delta_gain_code[i] =
@@ -860,7 +859,7 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp)
860 859
861 /* Make sure we accumulate data for just the associated channel 860 /* Make sure we accumulate data for just the associated channel
862 * (even if scanning). */ 861 * (even if scanning). */
863 if ((rxon_chnum != stat_chnum) || (rxon_band24 != stat_band24)) { 862 if (rxon_chnum != stat_chnum || rxon_band24 != stat_band24) {
864 D_CALIB("Stats not from chan=%d, band24=%d\n", 863 D_CALIB("Stats not from chan=%d, band24=%d\n",
865 rxon_chnum, rxon_band24); 864 rxon_chnum, rxon_band24);
866 spin_unlock_irqrestore(&il->lock, flags); 865 spin_unlock_irqrestore(&il->lock, flags);
@@ -920,8 +919,8 @@ void il4965_chain_noise_calibration(struct il_priv *il, void *stat_resp)
920 il->cfg->base_params->chain_noise_num_beacons; 919 il->cfg->base_params->chain_noise_num_beacons;
921 920
922 for (i = 0; i < NUM_RX_CHAINS; i++) { 921 for (i = 0; i < NUM_RX_CHAINS; i++) {
923 if (!(data->disconn_array[i]) && 922 if (!data->disconn_array[i] &&
924 (average_noise[i] <= min_average_noise)) { 923 average_noise[i] <= min_average_noise) {
925 /* This means that chain i is active and has 924 /* This means that chain i is active and has
926 * lower noise values so far: */ 925 * lower noise values so far: */
927 min_average_noise = average_noise[i]; 926 min_average_noise = average_noise[i];
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h
index b6b7fe2f5ca..b21c0040c20 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-hw.h
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-hw.h
@@ -102,8 +102,8 @@
102 102
103static inline int il4965_hw_valid_rtc_data_addr(u32 addr) 103static inline int il4965_hw_valid_rtc_data_addr(u32 addr)
104{ 104{
105 return (addr >= IWL49_RTC_DATA_LOWER_BOUND) && 105 return (addr >= IWL49_RTC_DATA_LOWER_BOUND &&
106 (addr < IWL49_RTC_DATA_UPPER_BOUND); 106 addr < IWL49_RTC_DATA_UPPER_BOUND);
107} 107}
108 108
109/********************* START TEMPERATURE *************************************/ 109/********************* START TEMPERATURE *************************************/
@@ -147,8 +147,8 @@ static inline int il4965_hw_valid_rtc_data_addr(u32 addr)
147#define IL_TX_POWER_TEMPERATURE_MAX (410) 147#define IL_TX_POWER_TEMPERATURE_MAX (410)
148 148
149#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \ 149#define IL_TX_POWER_TEMPERATURE_OUT_OF_RANGE(t) \
150 (((t) < IL_TX_POWER_TEMPERATURE_MIN) || \ 150 ((t) < IL_TX_POWER_TEMPERATURE_MIN || \
151 ((t) > IL_TX_POWER_TEMPERATURE_MAX)) 151 (t) > IL_TX_POWER_TEMPERATURE_MAX)
152 152
153/********************* END TEMPERATURE ***************************************/ 153/********************* END TEMPERATURE ***************************************/
154 154
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
index 8fafd201717..8bb2b6280d7 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-lib.c
@@ -234,7 +234,7 @@ void il4965_rx_queue_restock(struct il_priv *il)
234 unsigned long flags; 234 unsigned long flags;
235 235
236 spin_lock_irqsave(&rxq->lock, flags); 236 spin_lock_irqsave(&rxq->lock, flags);
237 while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { 237 while (il_rx_queue_space(rxq) > 0 && rxq->free_count) {
238 /* The overwritten rxb must be a used one */ 238 /* The overwritten rxb must be a used one */
239 rxb = rxq->queue[rxq->write]; 239 rxb = rxq->queue[rxq->write];
240 BUG_ON(rxb && rxb->page); 240 BUG_ON(rxb && rxb->page);
@@ -307,7 +307,7 @@ static void il4965_rx_allocate(struct il_priv *il, gfp_t priority)
307 "order: %d\n", 307 "order: %d\n",
308 il->hw_params.rx_page_order); 308 il->hw_params.rx_page_order);
309 309
310 if ((rxq->free_count <= RX_LOW_WATERMARK) && 310 if (rxq->free_count <= RX_LOW_WATERMARK &&
311 net_ratelimit()) 311 net_ratelimit())
312 IL_ERR( 312 IL_ERR(
313 "Failed to alloc_pages with %s. " 313 "Failed to alloc_pages with %s. "
@@ -1106,7 +1106,7 @@ void il4965_set_rxon_chain(struct il_priv *il, struct il_rxon_context *ctx)
1106 1106
1107 ctx->staging.rx_chain = cpu_to_le16(rx_chain); 1107 ctx->staging.rx_chain = cpu_to_le16(rx_chain);
1108 1108
1109 if (!is_single && (active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE) && is_cam) 1109 if (!is_single && active_rx_cnt >= IL_NUM_RX_CHAINS_SINGLE && is_cam)
1110 ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK; 1110 ctx->staging.rx_chain |= RXON_RX_CHAIN_MIMO_FORCE_MSK;
1111 else 1111 else
1112 ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK; 1112 ctx->staging.rx_chain &= ~RXON_RX_CHAIN_MIMO_FORCE_MSK;
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c
index 93bb31d628b..c2f42301014 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-rs.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-rs.c
@@ -127,7 +127,7 @@ static int il4965_hwrate_to_plcp_idx(u32 rate_n_flags)
127 /* skip 9M not supported in ht*/ 127 /* skip 9M not supported in ht*/
128 if (idx >= IL_RATE_9M_INDEX) 128 if (idx >= IL_RATE_9M_INDEX)
129 idx += 1; 129 idx += 1;
130 if ((idx >= IL_FIRST_OFDM_RATE) && (idx <= IL_LAST_OFDM_RATE)) 130 if (idx >= IL_FIRST_OFDM_RATE && idx <= IL_LAST_OFDM_RATE)
131 return idx; 131 return idx;
132 132
133 /* legacy rate format, search for match in table */ 133 /* legacy rate format, search for match in table */
@@ -251,8 +251,7 @@ il4965_rs_tl_rm_old_stats(struct il_traffic_load *tl, u32 curr_time)
251 /* The oldest age we want to keep */ 251 /* The oldest age we want to keep */
252 u32 oldest_time = curr_time - TID_MAX_TIME_DIFF; 252 u32 oldest_time = curr_time - TID_MAX_TIME_DIFF;
253 253
254 while (tl->queue_count && 254 while (tl->queue_count && tl->time_stamp < oldest_time) {
255 (tl->time_stamp < oldest_time)) {
256 tl->total -= tl->packet_count[tl->head]; 255 tl->total -= tl->packet_count[tl->head];
257 tl->packet_count[tl->head] = 0; 256 tl->packet_count[tl->head] = 0;
258 tl->time_stamp += TID_QUEUE_CELL_SPACING; 257 tl->time_stamp += TID_QUEUE_CELL_SPACING;
@@ -477,8 +476,8 @@ static int il4965_rs_collect_tx_data(struct il_scale_tbl_info *tbl,
477 fail_count = window->counter - window->success_counter; 476 fail_count = window->counter - window->success_counter;
478 477
479 /* Calculate average throughput, if we have enough history. */ 478 /* Calculate average throughput, if we have enough history. */
480 if ((fail_count >= IL_RATE_MIN_FAILURE_TH) || 479 if (fail_count >= IL_RATE_MIN_FAILURE_TH ||
481 (window->success_counter >= IL_RATE_MIN_SUCCESS_TH)) 480 window->success_counter >= IL_RATE_MIN_SUCCESS_TH)
482 window->average_tpt = (window->success_ratio * tpt + 64) / 128; 481 window->average_tpt = (window->success_ratio * tpt + 64) / 128;
483 else 482 else
484 window->average_tpt = IL_INVALID_VALUE; 483 window->average_tpt = IL_INVALID_VALUE;
@@ -619,7 +618,7 @@ static int il4965_rs_toggle_antenna(u32 valid_ant, u32 *rate_n_flags,
619 618
620 new_ant_type = ant_toggle_lookup[tbl->ant_type]; 619 new_ant_type = ant_toggle_lookup[tbl->ant_type];
621 620
622 while ((new_ant_type != tbl->ant_type) && 621 while (new_ant_type != tbl->ant_type &&
623 !il4965_rs_is_valid_ant(valid_ant, new_ant_type)) 622 !il4965_rs_is_valid_ant(valid_ant, new_ant_type))
624 new_ant_type = ant_toggle_lookup[new_ant_type]; 623 new_ant_type = ant_toggle_lookup[new_ant_type];
625 624
@@ -790,8 +789,8 @@ out:
790static bool il4965_table_type_matches(struct il_scale_tbl_info *a, 789static bool il4965_table_type_matches(struct il_scale_tbl_info *a,
791 struct il_scale_tbl_info *b) 790 struct il_scale_tbl_info *b)
792{ 791{
793 return (a->lq_type == b->lq_type) && (a->ant_type == b->ant_type) && 792 return (a->lq_type == b->lq_type && a->ant_type == b->ant_type &&
794 (a->is_SGI == b->is_SGI); 793 a->is_SGI == b->is_SGI);
795} 794}
796 795
797/* 796/*
@@ -830,7 +829,7 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband,
830 } 829 }
831 830
832 if (!ieee80211_is_data(hdr->frame_control) || 831 if (!ieee80211_is_data(hdr->frame_control) ||
833 info->flags & IEEE80211_TX_CTL_NO_ACK) 832 (info->flags & IEEE80211_TX_CTL_NO_ACK))
834 return; 833 return;
835 834
836 /* This packet was aggregated but doesn't carry status info */ 835 /* This packet was aggregated but doesn't carry status info */
@@ -867,19 +866,14 @@ il4965_rs_tx_status(void *il_r, struct ieee80211_supported_band *sband,
867 mac_index += IL_FIRST_OFDM_RATE; 866 mac_index += IL_FIRST_OFDM_RATE;
868 } 867 }
869 /* Here we actually compare this rate to the latest LQ command */ 868 /* Here we actually compare this rate to the latest LQ command */
870 if ((mac_index < 0) || 869 if (mac_index < 0 ||
871 (tbl_type.is_SGI != 870 tbl_type.is_SGI != !!(mac_flags & IEEE80211_TX_RC_SHORT_GI) ||
872 !!(mac_flags & IEEE80211_TX_RC_SHORT_GI)) || 871 tbl_type.is_ht40 != !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH) ||
873 (tbl_type.is_ht40 != 872 tbl_type.is_dup != !!(mac_flags & IEEE80211_TX_RC_DUP_DATA) ||
874 !!(mac_flags & IEEE80211_TX_RC_40_MHZ_WIDTH)) || 873 tbl_type.ant_type != info->antenna_sel_tx ||
875 (tbl_type.is_dup != 874 !!(tx_rate & RATE_MCS_HT_MSK) != !!(mac_flags & IEEE80211_TX_RC_MCS) ||
876 !!(mac_flags & IEEE80211_TX_RC_DUP_DATA)) || 875 !!(tx_rate & RATE_MCS_GF_MSK) != !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD) ||
877 (tbl_type.ant_type != info->antenna_sel_tx) || 876 rs_index != mac_index) {
878 (!!(tx_rate & RATE_MCS_HT_MSK) !=
879 !!(mac_flags & IEEE80211_TX_RC_MCS)) ||
880 (!!(tx_rate & RATE_MCS_GF_MSK) !=
881 !!(mac_flags & IEEE80211_TX_RC_GREEN_FIELD)) ||
882 (rs_index != mac_index)) {
883 D_RATE( 877 D_RATE(
884 "initial rate %d does not match %d (0x%x)\n", 878 "initial rate %d does not match %d (0x%x)\n",
885 mac_index, rs_index, tx_rate); 879 mac_index, rs_index, tx_rate);
@@ -1119,12 +1113,12 @@ static s32 il4965_rs_get_best_rate(struct il_priv *il,
1119 * conditions) at candidate rate is above expected 1113 * conditions) at candidate rate is above expected
1120 * "active" throughput (under perfect conditions). 1114 * "active" throughput (under perfect conditions).
1121 */ 1115 */
1122 if ((((100 * tpt_tbl[rate]) > lq_sta->last_tpt) && 1116 if ((100 * tpt_tbl[rate] > lq_sta->last_tpt &&
1123 ((active_sr > IL_RATE_DECREASE_TH) && 1117 (active_sr > IL_RATE_DECREASE_TH &&
1124 (active_sr <= IL_RATE_HIGH_TH) && 1118 active_sr <= IL_RATE_HIGH_TH &&
1125 (tpt_tbl[rate] <= active_tpt))) || 1119 tpt_tbl[rate] <= active_tpt)) ||
1126 ((active_sr >= IL_RATE_SCALE_SWITCH) && 1120 (active_sr >= IL_RATE_SCALE_SWITCH &&
1127 (tpt_tbl[rate] > active_tpt))) { 1121 tpt_tbl[rate] > active_tpt)) {
1128 1122
1129 /* (2nd or later pass) 1123 /* (2nd or later pass)
1130 * If we've already tried to raise the rate, and are 1124 * If we've already tried to raise the rate, and are
@@ -1213,7 +1207,7 @@ static int il4965_rs_switch_to_mimo2(struct il_priv *il,
1213 1207
1214 D_RATE("LQ: MIMO2 best rate %d mask %X\n", 1208 D_RATE("LQ: MIMO2 best rate %d mask %X\n",
1215 rate, rate_mask); 1209 rate, rate_mask);
1216 if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { 1210 if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) {
1217 D_RATE( 1211 D_RATE(
1218 "Can't switch with index %d rate mask %x\n", 1212 "Can't switch with index %d rate mask %x\n",
1219 rate, rate_mask); 1213 rate, rate_mask);
@@ -1265,7 +1259,7 @@ static int il4965_rs_switch_to_siso(struct il_priv *il,
1265 rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index); 1259 rate = il4965_rs_get_best_rate(il, lq_sta, tbl, rate_mask, index);
1266 1260
1267 D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask); 1261 D_RATE("LQ: get best rate %d mask %X\n", rate, rate_mask);
1268 if ((rate == IL_RATE_INVALID) || !((1 << rate) & rate_mask)) { 1262 if (rate == IL_RATE_INVALID || !((1 << rate) & rate_mask)) {
1269 D_RATE( 1263 D_RATE(
1270 "can not switch with index %d rate mask %x\n", 1264 "can not switch with index %d rate mask %x\n",
1271 rate, rate_mask); 1265 rate, rate_mask);
@@ -1680,10 +1674,10 @@ il4965_rs_stay_in_table(struct il_lq_sta *lq_sta, bool force_search)
1680 * stats in active history. 1674 * stats in active history.
1681 */ 1675 */
1682 if (force_search || 1676 if (force_search ||
1683 (lq_sta->total_failed > lq_sta->max_failure_limit) || 1677 lq_sta->total_failed > lq_sta->max_failure_limit ||
1684 (lq_sta->total_success > lq_sta->max_success_limit) || 1678 lq_sta->total_success > lq_sta->max_success_limit ||
1685 ((!lq_sta->search_better_tbl) && (lq_sta->flush_timer) 1679 (!lq_sta->search_better_tbl && lq_sta->flush_timer &&
1686 && (flush_interval_passed))) { 1680 flush_interval_passed)) {
1687 D_RATE("LQ: stay is expired %d %d %d\n:", 1681 D_RATE("LQ: stay is expired %d %d %d\n:",
1688 lq_sta->total_failed, 1682 lq_sta->total_failed,
1689 lq_sta->total_success, 1683 lq_sta->total_success,
@@ -1788,7 +1782,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il,
1788 /* Send management frames and NO_ACK data using lowest rate. */ 1782 /* Send management frames and NO_ACK data using lowest rate. */
1789 /* TODO: this could probably be improved.. */ 1783 /* TODO: this could probably be improved.. */
1790 if (!ieee80211_is_data(hdr->frame_control) || 1784 if (!ieee80211_is_data(hdr->frame_control) ||
1791 info->flags & IEEE80211_TX_CTL_NO_ACK) 1785 (info->flags & IEEE80211_TX_CTL_NO_ACK))
1792 return; 1786 return;
1793 1787
1794 if (!sta || !lq_sta) 1788 if (!sta || !lq_sta)
@@ -1797,7 +1791,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il,
1797 lq_sta->supp_rates = sta->supp_rates[lq_sta->band]; 1791 lq_sta->supp_rates = sta->supp_rates[lq_sta->band];
1798 1792
1799 tid = il4965_rs_tl_add_packet(lq_sta, hdr); 1793 tid = il4965_rs_tl_add_packet(lq_sta, hdr);
1800 if ((tid != MAX_TID_COUNT) && (lq_sta->tx_agg_tid_en & (1 << tid))) { 1794 if (tid != MAX_TID_COUNT && (lq_sta->tx_agg_tid_en & (1 << tid))) {
1801 tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid]; 1795 tid_data = &il->stations[lq_sta->lq.sta_id].tid[tid];
1802 if (tid_data->agg.state == IL_AGG_OFF) 1796 if (tid_data->agg.state == IL_AGG_OFF)
1803 lq_sta->is_agg = 0; 1797 lq_sta->is_agg = 0;
@@ -1872,8 +1866,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il,
1872 } 1866 }
1873 1867
1874 /* force user max rate if set by user */ 1868 /* force user max rate if set by user */
1875 if ((lq_sta->max_rate_idx != -1) && 1869 if (lq_sta->max_rate_idx != -1 &&
1876 (lq_sta->max_rate_idx < index)) { 1870 lq_sta->max_rate_idx < index) {
1877 index = lq_sta->max_rate_idx; 1871 index = lq_sta->max_rate_idx;
1878 update_lq = 1; 1872 update_lq = 1;
1879 window = &(tbl->win[index]); 1873 window = &(tbl->win[index]);
@@ -1890,8 +1884,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il,
1890 * in current association (use new rate found above). 1884 * in current association (use new rate found above).
1891 */ 1885 */
1892 fail_count = window->counter - window->success_counter; 1886 fail_count = window->counter - window->success_counter;
1893 if ((fail_count < IL_RATE_MIN_FAILURE_TH) && 1887 if (fail_count < IL_RATE_MIN_FAILURE_TH &&
1894 (window->success_counter < IL_RATE_MIN_SUCCESS_TH)) { 1888 window->success_counter < IL_RATE_MIN_SUCCESS_TH) {
1895 D_RATE("LQ: still below TH. succ=%d total=%d " 1889 D_RATE("LQ: still below TH. succ=%d total=%d "
1896 "for index %d\n", 1890 "for index %d\n",
1897 window->success_counter, window->counter, index); 1891 window->success_counter, window->counter, index);
@@ -1975,8 +1969,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il,
1975 high = (high_low >> 8) & 0xff; 1969 high = (high_low >> 8) & 0xff;
1976 1970
1977 /* If user set max rate, dont allow higher than user constrain */ 1971 /* If user set max rate, dont allow higher than user constrain */
1978 if ((lq_sta->max_rate_idx != -1) && 1972 if (lq_sta->max_rate_idx != -1 &&
1979 (lq_sta->max_rate_idx < high)) 1973 lq_sta->max_rate_idx < high)
1980 high = IL_RATE_INVALID; 1974 high = IL_RATE_INVALID;
1981 1975
1982 sr = window->success_ratio; 1976 sr = window->success_ratio;
@@ -1991,14 +1985,14 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il,
1991 scale_action = 0; 1985 scale_action = 0;
1992 1986
1993 /* Too many failures, decrease rate */ 1987 /* Too many failures, decrease rate */
1994 if ((sr <= IL_RATE_DECREASE_TH) || (current_tpt == 0)) { 1988 if (sr <= IL_RATE_DECREASE_TH || current_tpt == 0) {
1995 D_RATE( 1989 D_RATE(
1996 "decrease rate because of low success_ratio\n"); 1990 "decrease rate because of low success_ratio\n");
1997 scale_action = -1; 1991 scale_action = -1;
1998 1992
1999 /* No throughput measured yet for adjacent rates; try increase. */ 1993 /* No throughput measured yet for adjacent rates; try increase. */
2000 } else if ((low_tpt == IL_INVALID_VALUE) && 1994 } else if (low_tpt == IL_INVALID_VALUE &&
2001 (high_tpt == IL_INVALID_VALUE)) { 1995 high_tpt == IL_INVALID_VALUE) {
2002 1996
2003 if (high != IL_RATE_INVALID && sr >= IL_RATE_INCREASE_TH) 1997 if (high != IL_RATE_INVALID && sr >= IL_RATE_INCREASE_TH)
2004 scale_action = 1; 1998 scale_action = 1;
@@ -2008,10 +2002,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il,
2008 2002
2009 /* Both adjacent throughputs are measured, but neither one has better 2003 /* Both adjacent throughputs are measured, but neither one has better
2010 * throughput; we're using the best rate, don't change it! */ 2004 * throughput; we're using the best rate, don't change it! */
2011 else if ((low_tpt != IL_INVALID_VALUE) && 2005 else if (low_tpt != IL_INVALID_VALUE && high_tpt != IL_INVALID_VALUE &&
2012 (high_tpt != IL_INVALID_VALUE) && 2006 low_tpt < current_tpt && high_tpt < current_tpt)
2013 (low_tpt < current_tpt) &&
2014 (high_tpt < current_tpt))
2015 scale_action = 0; 2007 scale_action = 0;
2016 2008
2017 /* At least one adjacent rate's throughput is measured, 2009 /* At least one adjacent rate's throughput is measured,
@@ -2021,7 +2013,7 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il,
2021 if (high_tpt != IL_INVALID_VALUE) { 2013 if (high_tpt != IL_INVALID_VALUE) {
2022 /* Higher rate has better throughput */ 2014 /* Higher rate has better throughput */
2023 if (high_tpt > current_tpt && 2015 if (high_tpt > current_tpt &&
2024 sr >= IL_RATE_INCREASE_TH) { 2016 sr >= IL_RATE_INCREASE_TH) {
2025 scale_action = 1; 2017 scale_action = 1;
2026 } else { 2018 } else {
2027 scale_action = 0; 2019 scale_action = 0;
@@ -2042,9 +2034,8 @@ static void il4965_rs_rate_scale_perform(struct il_priv *il,
2042 2034
2043 /* Sanity check; asked for decrease, but success rate or throughput 2035 /* Sanity check; asked for decrease, but success rate or throughput
2044 * has been good at old rate. Don't change it. */ 2036 * has been good at old rate. Don't change it. */
2045 if ((scale_action == -1) && (low != IL_RATE_INVALID) && 2037 if (scale_action == -1 && low != IL_RATE_INVALID &&
2046 ((sr > IL_RATE_HIGH_TH) || 2038 (sr > IL_RATE_HIGH_TH || current_tpt > 100 * tbl->expected_tpt[low]))
2047 (current_tpt > (100 * tbl->expected_tpt[low]))))
2048 scale_action = 0; 2039 scale_action = 0;
2049 2040
2050 switch (scale_action) { 2041 switch (scale_action) {
@@ -2090,8 +2081,8 @@ lq_update:
2090 * 2) Not just finishing up a search 2081 * 2) Not just finishing up a search
2091 * 3) Allowing a new search 2082 * 3) Allowing a new search
2092 */ 2083 */
2093 if (!update_lq && !done_search && 2084 if (!update_lq && !done_search && !lq_sta->stay_in_tbl &&
2094 !lq_sta->stay_in_tbl && window->counter) { 2085 window->counter) {
2095 /* Save current throughput to compare with "search" throughput*/ 2086 /* Save current throughput to compare with "search" throughput*/
2096 lq_sta->last_tpt = current_tpt; 2087 lq_sta->last_tpt = current_tpt;
2097 2088
@@ -2146,10 +2137,10 @@ lq_update:
2146 * have been tried and compared, stay in this best modulation 2137 * have been tried and compared, stay in this best modulation
2147 * mode for a while before next round of mode comparisons. */ 2138 * mode for a while before next round of mode comparisons. */
2148 if (lq_sta->enable_counter && 2139 if (lq_sta->enable_counter &&
2149 (lq_sta->action_counter >= tbl1->max_search)) { 2140 lq_sta->action_counter >= tbl1->max_search) {
2150 if ((lq_sta->last_tpt > IL_AGG_TPT_THREHOLD) && 2141 if (lq_sta->last_tpt > IL_AGG_TPT_THREHOLD &&
2151 (lq_sta->tx_agg_tid_en & (1 << tid)) && 2142 (lq_sta->tx_agg_tid_en & (1 << tid)) &&
2152 (tid != MAX_TID_COUNT)) { 2143 tid != MAX_TID_COUNT) {
2153 tid_data = 2144 tid_data =
2154 &il->stations[lq_sta->lq.sta_id].tid[tid]; 2145 &il->stations[lq_sta->lq.sta_id].tid[tid];
2155 if (tid_data->agg.state == IL_AGG_OFF) { 2146 if (tid_data->agg.state == IL_AGG_OFF) {
@@ -2217,7 +2208,7 @@ static void il4965_rs_initialize_lq(struct il_priv *il,
2217 2208
2218 tbl = &(lq_sta->lq_info[active_tbl]); 2209 tbl = &(lq_sta->lq_info[active_tbl]);
2219 2210
2220 if ((i < 0) || (i >= IL_RATE_COUNT)) 2211 if (i < 0 || i >= IL_RATE_COUNT)
2221 i = 0; 2212 i = 0;
2222 2213
2223 rate = il_rates[i].plcp; 2214 rate = il_rates[i].plcp;
@@ -2256,11 +2247,11 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,
2256 /* Get max rate if user set max rate */ 2247 /* Get max rate if user set max rate */
2257 if (lq_sta) { 2248 if (lq_sta) {
2258 lq_sta->max_rate_idx = txrc->max_rate_idx; 2249 lq_sta->max_rate_idx = txrc->max_rate_idx;
2259 if ((sband->band == IEEE80211_BAND_5GHZ) && 2250 if (sband->band == IEEE80211_BAND_5GHZ &&
2260 (lq_sta->max_rate_idx != -1)) 2251 lq_sta->max_rate_idx != -1)
2261 lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE; 2252 lq_sta->max_rate_idx += IL_FIRST_OFDM_RATE;
2262 if ((lq_sta->max_rate_idx < 0) || 2253 if (lq_sta->max_rate_idx < 0 ||
2263 (lq_sta->max_rate_idx >= IL_RATE_COUNT)) 2254 lq_sta->max_rate_idx >= IL_RATE_COUNT)
2264 lq_sta->max_rate_idx = -1; 2255 lq_sta->max_rate_idx = -1;
2265 } 2256 }
2266 2257
@@ -2301,9 +2292,9 @@ il4965_rs_get_rate(void *il_r, struct ieee80211_sta *sta, void *il_sta,
2301 IEEE80211_TX_RC_GREEN_FIELD; 2292 IEEE80211_TX_RC_GREEN_FIELD;
2302 } else { 2293 } else {
2303 /* Check for invalid rates */ 2294 /* Check for invalid rates */
2304 if ((rate_idx < 0) || (rate_idx >= IL_RATE_COUNT_LEGACY) || 2295 if (rate_idx < 0 || rate_idx >= IL_RATE_COUNT_LEGACY ||
2305 ((sband->band == IEEE80211_BAND_5GHZ) && 2296 (sband->band == IEEE80211_BAND_5GHZ &&
2306 (rate_idx < IL_FIRST_OFDM_RATE))) 2297 rate_idx < IL_FIRST_OFDM_RATE))
2307 rate_idx = rate_lowest_index(sband, sta); 2298 rate_idx = rate_lowest_index(sband, sta);
2308 /* On valid 5 GHz rate, adjust index */ 2299 /* On valid 5 GHz rate, adjust index */
2309 else if (sband->band == IEEE80211_BAND_5GHZ) 2300 else if (sband->band == IEEE80211_BAND_5GHZ)
@@ -2475,7 +2466,7 @@ static void il4965_rs_fill_link_cmd(struct il_priv *il,
2475 /* Repeat initial/next rate. 2466 /* Repeat initial/next rate.
2476 * For legacy IL_NUMBER_TRY == 1, this loop will not execute. 2467 * For legacy IL_NUMBER_TRY == 1, this loop will not execute.
2477 * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */ 2468 * For HT IL_HT_NUMBER_TRY == 3, this executes twice. */
2478 while (repeat_rate > 0 && (index < LINK_QUAL_MAX_RETRY_NUM)) { 2469 while (repeat_rate > 0 && index < LINK_QUAL_MAX_RETRY_NUM) {
2479 if (is_legacy(tbl_type.lq_type)) { 2470 if (is_legacy(tbl_type.lq_type)) {
2480 if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE) 2471 if (ant_toggle_cnt < NUM_TRY_BEFORE_ANT_TOGGLE)
2481 ant_toggle_cnt++; 2472 ant_toggle_cnt++;
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
index f86a3b90fc4..a32a4f32b97 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965-tx.c
@@ -195,8 +195,8 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il,
195 * index is invalid. 195 * index is invalid.
196 */ 196 */
197 rate_idx = info->control.rates[0].idx; 197 rate_idx = info->control.rates[0].idx;
198 if (info->control.rates[0].flags & IEEE80211_TX_RC_MCS || 198 if ((info->control.rates[0].flags & IEEE80211_TX_RC_MCS) ||
199 (rate_idx < 0) || (rate_idx > IL_RATE_COUNT_LEGACY)) 199 rate_idx < 0 || rate_idx > IL_RATE_COUNT_LEGACY)
200 rate_idx = rate_lowest_index(&il->bands[info->band], 200 rate_idx = rate_lowest_index(&il->bands[info->band],
201 info->control.sta); 201 info->control.sta);
202 /* For 5 GHZ band, remap mac80211 rate indices into driver indices */ 202 /* For 5 GHZ band, remap mac80211 rate indices into driver indices */
@@ -208,7 +208,7 @@ static void il4965_tx_cmd_build_rate(struct il_priv *il,
208 rate_flags = 0; 208 rate_flags = 0;
209 209
210 /* Set CCK flag as needed */ 210 /* Set CCK flag as needed */
211 if ((rate_idx >= IL_FIRST_CCK_RATE) && (rate_idx <= IL_LAST_CCK_RATE)) 211 if (rate_idx >= IL_FIRST_CCK_RATE && rate_idx <= IL_LAST_CCK_RATE)
212 rate_flags |= RATE_MCS_CCK_MSK; 212 rate_flags |= RATE_MCS_CCK_MSK;
213 213
214 /* Set up antennas */ 214 /* Set up antennas */
@@ -535,8 +535,7 @@ int il4965_tx_skb(struct il_priv *il, struct sk_buff *skb)
535 if (sta_priv && sta_priv->client && !is_agg) 535 if (sta_priv && sta_priv->client && !is_agg)
536 atomic_inc(&sta_priv->pending_frames); 536 atomic_inc(&sta_priv->pending_frames);
537 537
538 if ((il_queue_space(q) < q->high_mark) && 538 if (il_queue_space(q) < q->high_mark && il->mac80211_registered) {
539 il->mac80211_registered) {
540 if (wait_write_ptr) { 539 if (wait_write_ptr) {
541 spin_lock_irqsave(&il->lock, flags); 540 spin_lock_irqsave(&il->lock, flags);
542 txq->need_update = 1; 541 txq->need_update = 1;
@@ -1050,8 +1049,8 @@ int il4965_txq_check_empty(struct il_priv *il,
1050 case IL_EMPTYING_HW_QUEUE_DELBA: 1049 case IL_EMPTYING_HW_QUEUE_DELBA:
1051 /* We are reclaiming the last packet of the */ 1050 /* We are reclaiming the last packet of the */
1052 /* aggregated HW queue */ 1051 /* aggregated HW queue */
1053 if ((txq_id == tid_data->agg.txq_id) && 1052 if (txq_id == tid_data->agg.txq_id &&
1054 (q->read_ptr == q->write_ptr)) { 1053 q->read_ptr == q->write_ptr) {
1055 u16 ssn = SEQ_TO_SN(tid_data->seq_number); 1054 u16 ssn = SEQ_TO_SN(tid_data->seq_number);
1056 int tx_fifo = il4965_get_fifo_from_tid(ctx, tid); 1055 int tx_fifo = il4965_get_fifo_from_tid(ctx, tid);
1057 D_HT( 1056 D_HT(
@@ -1114,7 +1113,7 @@ int il4965_tx_queue_reclaim(struct il_priv *il, int txq_id, int index)
1114 int nfreed = 0; 1113 int nfreed = 0;
1115 struct ieee80211_hdr *hdr; 1114 struct ieee80211_hdr *hdr;
1116 1115
1117 if ((index >= q->n_bd) || (il_queue_used(q, index) == 0)) { 1116 if (index >= q->n_bd || il_queue_used(q, index) == 0) {
1118 IL_ERR("Read index for DMA queue txq id (%d), index %d, " 1117 IL_ERR("Read index for DMA queue txq id (%d), index %d, "
1119 "is out of range [0-%d] %d %d.\n", txq_id, 1118 "is out of range [0-%d] %d %d.\n", txq_id,
1120 index, q->n_bd, q->write_ptr, q->read_ptr); 1119 index, q->n_bd, q->write_ptr, q->read_ptr);
@@ -1321,9 +1320,9 @@ void il4965_rx_reply_compressed_ba(struct il_priv *il,
1321 int freed = il4965_tx_queue_reclaim(il, scd_flow, index); 1320 int freed = il4965_tx_queue_reclaim(il, scd_flow, index);
1322 il4965_free_tfds_in_queue(il, sta_id, tid, freed); 1321 il4965_free_tfds_in_queue(il, sta_id, tid, freed);
1323 1322
1324 if ((il_queue_space(&txq->q) > txq->q.low_mark) && 1323 if (il_queue_space(&txq->q) > txq->q.low_mark &&
1325 il->mac80211_registered && 1324 il->mac80211_registered &&
1326 (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) 1325 agg->state != IL_EMPTYING_HW_QUEUE_DELBA)
1327 il_wake_queue(il, txq); 1326 il_wake_queue(il, txq);
1328 1327
1329 il4965_txq_check_empty(il, sta_id, tid, scd_flow); 1328 il4965_txq_check_empty(il, sta_id, tid, scd_flow);
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.c b/drivers/net/wireless/iwlegacy/iwl-4965.c
index a7450323a66..3706e47ce27 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965.c
+++ b/drivers/net/wireless/iwlegacy/iwl-4965.c
@@ -284,8 +284,8 @@ static bool iw4965_is_ht40_channel(__le32 rxon_flags)
284{ 284{
285 int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK) 285 int chan_mod = le32_to_cpu(rxon_flags & RXON_FLG_CHANNEL_MODE_MSK)
286 >> RXON_FLG_CHANNEL_MODE_POS; 286 >> RXON_FLG_CHANNEL_MODE_POS;
287 return ((chan_mod == CHANNEL_MODE_PURE_40) || 287 return (chan_mod == CHANNEL_MODE_PURE_40 ||
288 (chan_mod == CHANNEL_MODE_MIXED)); 288 chan_mod == CHANNEL_MODE_MIXED);
289} 289}
290 290
291static void il4965_nic_config(struct il_priv *il) 291static void il4965_nic_config(struct il_priv *il)
@@ -323,7 +323,7 @@ static void il4965_chain_noise_reset(struct il_priv *il)
323{ 323{
324 struct il_chain_noise_data *data = &(il->chain_noise_data); 324 struct il_chain_noise_data *data = &(il->chain_noise_data);
325 325
326 if ((data->state == IL_CHAIN_NOISE_ALIVE) && 326 if (data->state == IL_CHAIN_NOISE_ALIVE &&
327 il_is_any_associated(il)) { 327 il_is_any_associated(il)) {
328 struct il_calib_diff_gain_cmd cmd; 328 struct il_calib_diff_gain_cmd cmd;
329 329
@@ -458,8 +458,8 @@ static s32 il4965_get_voltage_compensation(s32 eeprom_voltage,
458{ 458{
459 s32 comp = 0; 459 s32 comp = 0;
460 460
461 if ((TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage) || 461 if (TX_POWER_IL_ILLEGAL_VOLTAGE == eeprom_voltage ||
462 (TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage)) 462 TX_POWER_IL_ILLEGAL_VOLTAGE == current_voltage)
463 return 0; 463 return 0;
464 464
465 il4965_math_div_round(current_voltage - eeprom_voltage, 465 il4965_math_div_round(current_voltage - eeprom_voltage,
@@ -506,8 +506,8 @@ static u32 il4965_get_sub_band(const struct il_priv *il, u32 channel)
506 if (il->calib_info->band_info[b].ch_from == 0) 506 if (il->calib_info->band_info[b].ch_from == 0)
507 continue; 507 continue;
508 508
509 if ((channel >= il->calib_info->band_info[b].ch_from) 509 if (channel >= il->calib_info->band_info[b].ch_from &&
510 && (channel <= il->calib_info->band_info[b].ch_to)) 510 channel <= il->calib_info->band_info[b].ch_to)
511 break; 511 break;
512 } 512 }
513 513
@@ -1158,15 +1158,15 @@ static int il4965_send_rxon_assoc(struct il_priv *il,
1158 const struct il_rxon_cmd *rxon1 = &ctx->staging; 1158 const struct il_rxon_cmd *rxon1 = &ctx->staging;
1159 const struct il_rxon_cmd *rxon2 = &ctx->active; 1159 const struct il_rxon_cmd *rxon2 = &ctx->active;
1160 1160
1161 if ((rxon1->flags == rxon2->flags) && 1161 if (rxon1->flags == rxon2->flags &&
1162 (rxon1->filter_flags == rxon2->filter_flags) && 1162 rxon1->filter_flags == rxon2->filter_flags &&
1163 (rxon1->cck_basic_rates == rxon2->cck_basic_rates) && 1163 rxon1->cck_basic_rates == rxon2->cck_basic_rates &&
1164 (rxon1->ofdm_ht_single_stream_basic_rates == 1164 rxon1->ofdm_ht_single_stream_basic_rates ==
1165 rxon2->ofdm_ht_single_stream_basic_rates) && 1165 rxon2->ofdm_ht_single_stream_basic_rates &&
1166 (rxon1->ofdm_ht_dual_stream_basic_rates == 1166 rxon1->ofdm_ht_dual_stream_basic_rates ==
1167 rxon2->ofdm_ht_dual_stream_basic_rates) && 1167 rxon2->ofdm_ht_dual_stream_basic_rates &&
1168 (rxon1->rx_chain == rxon2->rx_chain) && 1168 rxon1->rx_chain == rxon2->rx_chain &&
1169 (rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates)) { 1169 rxon1->ofdm_basic_rates == rxon2->ofdm_basic_rates) {
1170 D_INFO("Using current RXON_ASSOC. Not resending.\n"); 1170 D_INFO("Using current RXON_ASSOC. Not resending.\n");
1171 return 0; 1171 return 0;
1172 } 1172 }
@@ -1216,7 +1216,7 @@ static int il4965_commit_rxon(struct il_priv *il, struct il_rxon_context *ctx)
1216 * abort any previous channel switch if still in process 1216 * abort any previous channel switch if still in process
1217 */ 1217 */
1218 if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) && 1218 if (test_bit(STATUS_CHANNEL_SWITCH_PENDING, &il->status) &&
1219 (il->switch_channel != ctx->staging.channel)) { 1219 il->switch_channel != ctx->staging.channel) {
1220 D_11H("abort channel switch on %d\n", 1220 D_11H("abort channel switch on %d\n",
1221 le16_to_cpu(il->switch_channel)); 1221 le16_to_cpu(il->switch_channel));
1222 il_chswitch_done(il, false); 1222 il_chswitch_done(il, false);
@@ -1366,7 +1366,7 @@ static int il4965_hw_channel_switch(struct il_priv *il,
1366 * calculate the ucode channel switch time 1366 * calculate the ucode channel switch time
1367 * adding TSF as one of the factor for when to switch 1367 * adding TSF as one of the factor for when to switch
1368 */ 1368 */
1369 if ((il->ucode_beacon_time > tsf_low) && beacon_interval) { 1369 if (il->ucode_beacon_time > tsf_low && beacon_interval) {
1370 if (switch_count > ((il->ucode_beacon_time - tsf_low) / 1370 if (switch_count > ((il->ucode_beacon_time - tsf_low) /
1371 beacon_interval)) { 1371 beacon_interval)) {
1372 switch_count -= (il->ucode_beacon_time - 1372 switch_count -= (il->ucode_beacon_time -
@@ -1789,7 +1789,7 @@ static void il4965_rx_reply_tx(struct il_priv *il,
1789 u8 *qc = NULL; 1789 u8 *qc = NULL;
1790 unsigned long flags; 1790 unsigned long flags;
1791 1791
1792 if ((index >= txq->q.n_bd) || (il_queue_used(&txq->q, index) == 0)) { 1792 if (index >= txq->q.n_bd || il_queue_used(&txq->q, index) == 0) {
1793 IL_ERR("Read index for DMA queue txq_id (%d) index %d " 1793 IL_ERR("Read index for DMA queue txq_id (%d) index %d "
1794 "is out of range [0-%d] %d %d\n", txq_id, 1794 "is out of range [0-%d] %d %d\n", txq_id,
1795 index, txq->q.n_bd, txq->q.write_ptr, 1795 index, txq->q.n_bd, txq->q.write_ptr,
@@ -1838,8 +1838,8 @@ static void il4965_rx_reply_tx(struct il_priv *il,
1838 tid, freed); 1838 tid, freed);
1839 1839
1840 if (il->mac80211_registered && 1840 if (il->mac80211_registered &&
1841 (il_queue_space(&txq->q) > txq->q.low_mark) 1841 il_queue_space(&txq->q) > txq->q.low_mark &&
1842 && (agg->state != IL_EMPTYING_HW_QUEUE_DELBA)) 1842 agg->state != IL_EMPTYING_HW_QUEUE_DELBA)
1843 il_wake_queue(il, txq); 1843 il_wake_queue(il, txq);
1844 } 1844 }
1845 } else { 1845 } else {
@@ -1863,7 +1863,7 @@ static void il4965_rx_reply_tx(struct il_priv *il,
1863 D_TX_REPLY("Station not known\n"); 1863 D_TX_REPLY("Station not known\n");
1864 1864
1865 if (il->mac80211_registered && 1865 if (il->mac80211_registered &&
1866 (il_queue_space(&txq->q) > txq->q.low_mark)) 1866 il_queue_space(&txq->q) > txq->q.low_mark)
1867 il_wake_queue(il, txq); 1867 il_wake_queue(il, txq);
1868 } 1868 }
1869 if (qc && likely(sta_id != IL_INVALID_STATION)) 1869 if (qc && likely(sta_id != IL_INVALID_STATION))
diff --git a/drivers/net/wireless/iwlegacy/iwl-4965.h b/drivers/net/wireless/iwlegacy/iwl-4965.h
index ea2a98e3a4a..56bfdb01604 100644
--- a/drivers/net/wireless/iwlegacy/iwl-4965.h
+++ b/drivers/net/wireless/iwlegacy/iwl-4965.h
@@ -163,8 +163,8 @@ static inline u32 il4965_tx_status_to_mac80211(u32 status)
163static inline bool il4965_is_tx_success(u32 status) 163static inline bool il4965_is_tx_success(u32 status)
164{ 164{
165 status &= TX_STATUS_MSK; 165 status &= TX_STATUS_MSK;
166 return (status == TX_STATUS_SUCCESS) || 166 return (status == TX_STATUS_SUCCESS ||
167 (status == TX_STATUS_DIRECT_DONE); 167 status == TX_STATUS_DIRECT_DONE);
168} 168}
169 169
170u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid); 170u8 il4965_toggle_tx_ant(struct il_priv *il, u8 ant_idx, u8 valid);
diff --git a/drivers/net/wireless/iwlegacy/iwl-core.c b/drivers/net/wireless/iwlegacy/iwl-core.c
index ed4415988e9..acbd5a89956 100644
--- a/drivers/net/wireless/iwlegacy/iwl-core.c
+++ b/drivers/net/wireless/iwlegacy/iwl-core.c
@@ -251,8 +251,8 @@ int il_init_geos(struct il_priv *il)
251 il->tx_power_user_lmt = max_tx_power; 251 il->tx_power_user_lmt = max_tx_power;
252 il->tx_power_next = max_tx_power; 252 il->tx_power_next = max_tx_power;
253 253
254 if ((il->bands[IEEE80211_BAND_5GHZ].n_channels == 0) && 254 if (il->bands[IEEE80211_BAND_5GHZ].n_channels == 0 &&
255 il->cfg->sku & IL_SKU_A) { 255 (il->cfg->sku & IL_SKU_A)) {
256 IL_INFO("Incorrectly detected BG card as ABG. " 256 IL_INFO("Incorrectly detected BG card as ABG. "
257 "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n", 257 "Please send your PCI ID 0x%04X:0x%04X to maintainer.\n",
258 il->pci_dev->device, 258 il->pci_dev->device,
@@ -708,8 +708,7 @@ il_set_rxon_channel(struct il_priv *il, struct ieee80211_channel *ch,
708 enum ieee80211_band band = ch->band; 708 enum ieee80211_band band = ch->band;
709 u16 channel = ch->hw_value; 709 u16 channel = ch->hw_value;
710 710
711 if ((le16_to_cpu(ctx->staging.channel) == channel) && 711 if (le16_to_cpu(ctx->staging.channel) == channel && il->band == band)
712 (il->band == band))
713 return 0; 712 return 0;
714 713
715 ctx->staging.channel = cpu_to_le16(channel); 714 ctx->staging.channel = cpu_to_le16(channel);
@@ -2306,8 +2305,8 @@ static void il_ht_conf(struct il_priv *il,
2306 >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT; 2305 >> IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT;
2307 maxstreams += 1; 2306 maxstreams += 1;
2308 2307
2309 if ((ht_cap->mcs.rx_mask[1] == 0) && 2308 if (ht_cap->mcs.rx_mask[1] == 0 &&
2310 (ht_cap->mcs.rx_mask[2] == 0)) 2309 ht_cap->mcs.rx_mask[2] == 0)
2311 ht_conf->single_chain_sufficient = true; 2310 ht_conf->single_chain_sufficient = true;
2312 if (maxstreams <= 1) 2311 if (maxstreams <= 1)
2313 ht_conf->single_chain_sufficient = true; 2312 ht_conf->single_chain_sufficient = true;
@@ -2467,7 +2466,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw,
2467 * mac80211 decides to do both changes at once because 2466 * mac80211 decides to do both changes at once because
2468 * it will invoke post_associate. 2467 * it will invoke post_associate.
2469 */ 2468 */
2470 if (vif->type == NL80211_IFTYPE_ADHOC && changes & BSS_CHANGED_BEACON) 2469 if (vif->type == NL80211_IFTYPE_ADHOC && (changes & BSS_CHANGED_BEACON))
2471 il_beacon_update(hw, vif); 2470 il_beacon_update(hw, vif);
2472 2471
2473 if (changes & BSS_CHANGED_ERP_PREAMBLE) { 2472 if (changes & BSS_CHANGED_ERP_PREAMBLE) {
@@ -2482,8 +2481,7 @@ void il_mac_bss_info_changed(struct ieee80211_hw *hw,
2482 if (changes & BSS_CHANGED_ERP_CTS_PROT) { 2481 if (changes & BSS_CHANGED_ERP_CTS_PROT) {
2483 D_MAC80211( 2482 D_MAC80211(
2484 "ERP_CTS %d\n", bss_conf->use_cts_prot); 2483 "ERP_CTS %d\n", bss_conf->use_cts_prot);
2485 if (bss_conf->use_cts_prot && 2484 if (bss_conf->use_cts_prot && il->band != IEEE80211_BAND_5GHZ)
2486 (il->band != IEEE80211_BAND_5GHZ))
2487 ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK; 2485 ctx->staging.flags |= RXON_FLG_TGG_PROTECT_MSK;
2488 else 2486 else
2489 ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK; 2487 ctx->staging.flags &= ~RXON_FLG_TGG_PROTECT_MSK;
@@ -2596,7 +2594,7 @@ irqreturn_t il_isr(int irq, void *data)
2596 goto none; 2594 goto none;
2597 } 2595 }
2598 2596
2599 if ((inta == 0xFFFFFFFF) || ((inta & 0xFFFFFFF0) == 0xa5a5a5a0)) { 2597 if (inta == 0xFFFFFFFF || (inta & 0xFFFFFFF0) == 0xa5a5a5a0) {
2600 /* Hardware disappeared. It might have already raised 2598 /* Hardware disappeared. It might have already raised
2601 * an interrupt */ 2599 * an interrupt */
2602 IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta); 2600 IL_WARN("HARDWARE GONE?? INTA == 0x%08x\n", inta);
diff --git a/drivers/net/wireless/iwlegacy/iwl-io.h b/drivers/net/wireless/iwlegacy/iwl-io.h
index 8cb924d1e26..9d33da82a79 100644
--- a/drivers/net/wireless/iwlegacy/iwl-io.h
+++ b/drivers/net/wireless/iwlegacy/iwl-io.h
@@ -176,7 +176,7 @@ static inline void il_write_reg_buf(struct il_priv *il,
176{ 176{
177 u32 count = sizeof(u32); 177 u32 count = sizeof(u32);
178 178
179 if ((il != NULL) && (values != NULL)) { 179 if (il != NULL && values != NULL) {
180 for (; 0 < len; len -= count, reg += count, values++) 180 for (; 0 < len; len -= count, reg += count, values++)
181 il_wr(il, reg, *values); 181 il_wr(il, reg, *values);
182 } 182 }
diff --git a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h
index 744829a6628..5da7d415170 100644
--- a/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h
+++ b/drivers/net/wireless/iwlegacy/iwl-legacy-rs.h
@@ -279,7 +279,7 @@ enum il_table_type {
279 LQ_MAX, 279 LQ_MAX,
280}; 280};
281 281
282#define is_legacy(tbl) (((tbl) == LQ_G) || ((tbl) == LQ_A)) 282#define is_legacy(tbl) ((tbl) == LQ_G || (tbl) == LQ_A)
283#define is_siso(tbl) ((tbl) == LQ_SISO) 283#define is_siso(tbl) ((tbl) == LQ_SISO)
284#define is_mimo2(tbl) ((tbl) == LQ_MIMO2) 284#define is_mimo2(tbl) ((tbl) == LQ_MIMO2)
285#define is_mimo(tbl) (is_mimo2(tbl)) 285#define is_mimo(tbl) (is_mimo2(tbl))
diff --git a/drivers/net/wireless/iwlegacy/iwl-scan.c b/drivers/net/wireless/iwlegacy/iwl-scan.c
index 36871041cec..e352a185a96 100644
--- a/drivers/net/wireless/iwlegacy/iwl-scan.c
+++ b/drivers/net/wireless/iwlegacy/iwl-scan.c
@@ -307,7 +307,7 @@ u16 il_get_passive_dwell_time(struct il_priv *il,
307 if (!il_is_associated_ctx(ctx)) 307 if (!il_is_associated_ctx(ctx))
308 continue; 308 continue;
309 value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0; 309 value = ctx->vif ? ctx->vif->bss_conf.beacon_int : 0;
310 if ((value > IL_PASSIVE_DWELL_BASE) || !value) 310 if (value > IL_PASSIVE_DWELL_BASE || !value)
311 value = IL_PASSIVE_DWELL_BASE; 311 value = IL_PASSIVE_DWELL_BASE;
312 value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2; 312 value = (value * 98) / 100 - IL_CHANNEL_TUNE_TIME * 2;
313 passive = min(value, passive); 313 passive = min(value, passive);
diff --git a/drivers/net/wireless/iwlegacy/iwl-sta.c b/drivers/net/wireless/iwlegacy/iwl-sta.c
index 42033d2ef6d..cca467c26c0 100644
--- a/drivers/net/wireless/iwlegacy/iwl-sta.c
+++ b/drivers/net/wireless/iwlegacy/iwl-sta.c
@@ -595,7 +595,7 @@ il_restore_stations(struct il_priv *il, struct il_rxon_context *ctx)
595 if (ctx->ctxid != il->stations[i].ctxid) 595 if (ctx->ctxid != il->stations[i].ctxid)
596 continue; 596 continue;
597 if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) && 597 if ((il->stations[i].used & IL_STA_DRIVER_ACTIVE) &&
598 !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) { 598 !(il->stations[i].used & IL_STA_UCODE_ACTIVE)) {
599 D_ASSOC("Restoring sta %pM\n", 599 D_ASSOC("Restoring sta %pM\n",
600 il->stations[i].sta.sta.addr); 600 il->stations[i].sta.sta.addr);
601 il->stations[i].sta.mode = 0; 601 il->stations[i].sta.mode = 0;
diff --git a/drivers/net/wireless/iwlegacy/iwl-tx.c b/drivers/net/wireless/iwlegacy/iwl-tx.c
index fa23c983ef9..0d3515d21bf 100644
--- a/drivers/net/wireless/iwlegacy/iwl-tx.c
+++ b/drivers/net/wireless/iwlegacy/iwl-tx.c
@@ -565,7 +565,7 @@ static void il_hcmd_queue_reclaim(struct il_priv *il, int txq_id,
565 struct il_queue *q = &txq->q; 565 struct il_queue *q = &txq->q;
566 int nfreed = 0; 566 int nfreed = 0;
567 567
568 if ((idx >= q->n_bd) || (il_queue_used(q, idx) == 0)) { 568 if (idx >= q->n_bd || il_queue_used(q, idx) == 0) {
569 IL_ERR("Read index for DMA queue txq id (%d), index %d, " 569 IL_ERR("Read index for DMA queue txq id (%d), index %d, "
570 "is out of range [0-%d] %d %d.\n", txq_id, 570 "is out of range [0-%d] %d %d.\n", txq_id,
571 idx, q->n_bd, q->write_ptr, q->read_ptr); 571 idx, q->n_bd, q->write_ptr, q->read_ptr);
diff --git a/drivers/net/wireless/iwlegacy/iwl3945-base.c b/drivers/net/wireless/iwlegacy/iwl3945-base.c
index 5037216041c..ec9a93c9cb8 100644
--- a/drivers/net/wireless/iwlegacy/iwl3945-base.c
+++ b/drivers/net/wireless/iwlegacy/iwl3945-base.c
@@ -646,7 +646,7 @@ static int il3945_tx_skb(struct il_priv *il, struct sk_buff *skb)
646 il_txq_update_write_ptr(il, txq); 646 il_txq_update_write_ptr(il, txq);
647 spin_unlock_irqrestore(&il->lock, flags); 647 spin_unlock_irqrestore(&il->lock, flags);
648 648
649 if ((il_queue_space(q) < q->high_mark) 649 if (il_queue_space(q) < q->high_mark
650 && il->mac80211_registered) { 650 && il->mac80211_registered) {
651 if (wait_write_ptr) { 651 if (wait_write_ptr) {
652 spin_lock_irqsave(&il->lock, flags); 652 spin_lock_irqsave(&il->lock, flags);
@@ -974,7 +974,7 @@ static void il3945_rx_queue_restock(struct il_priv *il)
974 974
975 spin_lock_irqsave(&rxq->lock, flags); 975 spin_lock_irqsave(&rxq->lock, flags);
976 write = rxq->write & ~0x7; 976 write = rxq->write & ~0x7;
977 while ((il_rx_queue_space(rxq) > 0) && (rxq->free_count)) { 977 while (il_rx_queue_space(rxq) > 0 && rxq->free_count) {
978 /* Get next free Rx buffer, remove from free list */ 978 /* Get next free Rx buffer, remove from free list */
979 element = rxq->rx_free.next; 979 element = rxq->rx_free.next;
980 rxb = list_entry(element, struct il_rx_mem_buffer, list); 980 rxb = list_entry(element, struct il_rx_mem_buffer, list);
@@ -995,8 +995,8 @@ static void il3945_rx_queue_restock(struct il_priv *il)
995 995
996 /* If we've added more space for the firmware to place data, tell it. 996 /* If we've added more space for the firmware to place data, tell it.
997 * Increment device's write pointer in multiples of 8. */ 997 * Increment device's write pointer in multiples of 8. */
998 if ((rxq->write_actual != (rxq->write & ~0x7)) 998 if (rxq->write_actual != (rxq->write & ~0x7) ||
999 || (abs(rxq->write - rxq->read) > 7)) { 999 abs(rxq->write - rxq->read) > 7) {
1000 spin_lock_irqsave(&rxq->lock, flags); 1000 spin_lock_irqsave(&rxq->lock, flags);
1001 rxq->need_update = 1; 1001 rxq->need_update = 1;
1002 spin_unlock_irqrestore(&rxq->lock, flags); 1002 spin_unlock_irqrestore(&rxq->lock, flags);
@@ -1041,7 +1041,7 @@ static void il3945_rx_allocate(struct il_priv *il, gfp_t priority)
1041 if (!page) { 1041 if (!page) {
1042 if (net_ratelimit()) 1042 if (net_ratelimit())
1043 D_INFO("Failed to allocate SKB buffer.\n"); 1043 D_INFO("Failed to allocate SKB buffer.\n");
1044 if ((rxq->free_count <= RX_LOW_WATERMARK) && 1044 if (rxq->free_count <= RX_LOW_WATERMARK &&
1045 net_ratelimit()) 1045 net_ratelimit())
1046 IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n", 1046 IL_ERR("Failed to allocate SKB buffer with %s. Only %u free buffers remaining.\n",
1047 priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL", 1047 priority == GFP_ATOMIC ? "GFP_ATOMIC" : "GFP_KERNEL",
@@ -1254,8 +1254,8 @@ static void il3945_rx_handle(struct il_priv *il)
1254 * Ucode should set SEQ_RX_FRAME bit if ucode-originated, 1254 * Ucode should set SEQ_RX_FRAME bit if ucode-originated,
1255 * but apparently a few don't get set; catch them here. */ 1255 * but apparently a few don't get set; catch them here. */
1256 reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) && 1256 reclaim = !(pkt->hdr.sequence & SEQ_RX_FRAME) &&
1257 (pkt->hdr.cmd != STATISTICS_NOTIFICATION) && 1257 pkt->hdr.cmd != STATISTICS_NOTIFICATION &&
1258 (pkt->hdr.cmd != REPLY_TX); 1258 pkt->hdr.cmd != REPLY_TX;
1259 1259
1260 /* Based on type of command response or notification, 1260 /* Based on type of command response or notification,
1261 * handle those that need handling via function in 1261 * handle those that need handling via function in
@@ -1659,7 +1659,7 @@ static void il3945_init_hw_rates(struct il_priv *il,
1659 rates[i].hw_value = i; /* Rate scaling will work on indexes */ 1659 rates[i].hw_value = i; /* Rate scaling will work on indexes */
1660 rates[i].hw_value_short = i; 1660 rates[i].hw_value_short = i;
1661 rates[i].flags = 0; 1661 rates[i].flags = 0;
1662 if ((i > IWL39_LAST_OFDM_RATE) || (i < IL_FIRST_OFDM_RATE)) { 1662 if (i > IWL39_LAST_OFDM_RATE || i < IL_FIRST_OFDM_RATE) {
1663 /* 1663 /*
1664 * If CCK != 1M then set short preamble rate flag. 1664 * If CCK != 1M then set short preamble rate flag.
1665 */ 1665 */
@@ -3294,7 +3294,7 @@ static ssize_t il3945_show_measurement(struct device *d,
3294 il->measurement_status = 0; 3294 il->measurement_status = 0;
3295 spin_unlock_irqrestore(&il->lock, flags); 3295 spin_unlock_irqrestore(&il->lock, flags);
3296 3296
3297 while (size && (PAGE_SIZE - len)) { 3297 while (size && PAGE_SIZE - len) {
3298 hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len, 3298 hex_dump_to_buffer(data + ofs, size, 16, 1, buf + len,
3299 PAGE_SIZE - len, 1); 3299 PAGE_SIZE - len, 1);
3300 len = strlen(buf); 3300 len = strlen(buf);
@@ -3406,7 +3406,7 @@ static ssize_t il3945_store_antenna(struct device *d,
3406 return count; 3406 return count;
3407 } 3407 }
3408 3408
3409 if ((ant >= 0) && (ant <= 2)) { 3409 if (ant >= 0 && ant <= 2) {
3410 D_INFO("Setting antenna select to %d.\n", ant); 3410 D_INFO("Setting antenna select to %d.\n", ant);
3411 il3945_mod_params.antenna = (enum il3945_antenna)ant; 3411 il3945_mod_params.antenna = (enum il3945_antenna)ant;
3412 } else 3412 } else