aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
authorDavid Spinadel <david.spinadel@intel.com>2012-05-11 04:53:15 -0400
committerJohn W. Linville <linville@tuxdriver.com>2012-05-16 13:08:17 -0400
commit0ed462875a7825e89674f3e7ff9d67835feb9f73 (patch)
treefbd4b3dad3a84f290f80f3cf372fdc71a62fd496 /drivers/net
parentcd6c65981e72aef9f5cc42ffe64404542162790a (diff)
iwlwifi: fix scan_cmd_size allocation
Allocate scan command with dynamic size based on uCode capability and num of channels. This isn't an important fix as the previous allocation was always too large as it added the scan command size but later subtracted it (which meant it was supposed to be part of the max scan size.) Signed-off-by: David Spinadel <david.spinadel@intel.com> Reviewed-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com> Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-commands.h1
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-scan.c17
2 files changed, 12 insertions, 6 deletions
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h
index 2813a0a89ed6..9af6a239b384 100644
--- a/drivers/net/wireless/iwlwifi/iwl-commands.h
+++ b/drivers/net/wireless/iwlwifi/iwl-commands.h
@@ -2278,7 +2278,6 @@ struct iwl_ssid_ie {
2278#define IWL_GOOD_CRC_TH_DISABLED 0 2278#define IWL_GOOD_CRC_TH_DISABLED 0
2279#define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1) 2279#define IWL_GOOD_CRC_TH_DEFAULT cpu_to_le16(1)
2280#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff) 2280#define IWL_GOOD_CRC_TH_NEVER cpu_to_le16(0xffff)
2281#define IWL_MAX_SCAN_SIZE 1024
2282#define IWL_MAX_CMD_SIZE 4096 2281#define IWL_MAX_CMD_SIZE 4096
2283 2282
2284/* 2283/*
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c
index a8437a6bc18e..6f221de5a76a 100644
--- a/drivers/net/wireless/iwlwifi/iwl-scan.c
+++ b/drivers/net/wireless/iwlwifi/iwl-scan.c
@@ -52,6 +52,7 @@
52#define IWL_PASSIVE_DWELL_TIME_52 (10) 52#define IWL_PASSIVE_DWELL_TIME_52 (10)
53#define IWL_PASSIVE_DWELL_BASE (100) 53#define IWL_PASSIVE_DWELL_BASE (100)
54#define IWL_CHANNEL_TUNE_TIME 5 54#define IWL_CHANNEL_TUNE_TIME 5
55#define MAX_SCAN_CHANNEL 50
55 56
56static int iwl_send_scan_abort(struct iwl_priv *priv) 57static int iwl_send_scan_abort(struct iwl_priv *priv)
57{ 58{
@@ -679,6 +680,13 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
679 u8 active_chains; 680 u8 active_chains;
680 u8 scan_tx_antennas = priv->hw_params.valid_tx_ant; 681 u8 scan_tx_antennas = priv->hw_params.valid_tx_ant;
681 int ret; 682 int ret;
683 int scan_cmd_size = sizeof(struct iwl_scan_cmd) +
684 MAX_SCAN_CHANNEL * sizeof(struct iwl_scan_channel) +
685 priv->fw->ucode_capa.max_probe_length;
686
687 if (WARN_ON_ONCE(priv->scan_request &&
688 priv->scan_request->n_channels > MAX_SCAN_CHANNEL))
689 return -EINVAL;
682 690
683 lockdep_assert_held(&priv->mutex); 691 lockdep_assert_held(&priv->mutex);
684 692
@@ -686,8 +694,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
686 ctx = iwl_rxon_ctx_from_vif(vif); 694 ctx = iwl_rxon_ctx_from_vif(vif);
687 695
688 if (!priv->scan_cmd) { 696 if (!priv->scan_cmd) {
689 priv->scan_cmd = kmalloc(sizeof(struct iwl_scan_cmd) + 697 priv->scan_cmd = kmalloc(scan_cmd_size, GFP_KERNEL);
690 IWL_MAX_SCAN_SIZE, GFP_KERNEL);
691 if (!priv->scan_cmd) { 698 if (!priv->scan_cmd) {
692 IWL_DEBUG_SCAN(priv, 699 IWL_DEBUG_SCAN(priv,
693 "fail to allocate memory for scan\n"); 700 "fail to allocate memory for scan\n");
@@ -695,7 +702,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
695 } 702 }
696 } 703 }
697 scan = priv->scan_cmd; 704 scan = priv->scan_cmd;
698 memset(scan, 0, sizeof(struct iwl_scan_cmd) + IWL_MAX_SCAN_SIZE); 705 memset(scan, 0, scan_cmd_size);
699 706
700 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH; 707 scan->quiet_plcp_th = IWL_PLCP_QUIET_THRESH;
701 scan->quiet_time = IWL_ACTIVE_QUIET_TIME; 708 scan->quiet_time = IWL_ACTIVE_QUIET_TIME;
@@ -883,7 +890,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
883 vif->addr, 890 vif->addr,
884 priv->scan_request->ie, 891 priv->scan_request->ie,
885 priv->scan_request->ie_len, 892 priv->scan_request->ie_len,
886 IWL_MAX_SCAN_SIZE - sizeof(*scan)); 893 scan_cmd_size - sizeof(*scan));
887 break; 894 break;
888 case IWL_SCAN_RADIO_RESET: 895 case IWL_SCAN_RADIO_RESET:
889 case IWL_SCAN_ROC: 896 case IWL_SCAN_ROC:
@@ -891,7 +898,7 @@ static int iwlagn_request_scan(struct iwl_priv *priv, struct ieee80211_vif *vif)
891 cmd_len = iwl_fill_probe_req( 898 cmd_len = iwl_fill_probe_req(
892 (struct ieee80211_mgmt *)scan->data, 899 (struct ieee80211_mgmt *)scan->data,
893 iwl_bcast_addr, NULL, 0, 900 iwl_bcast_addr, NULL, 0,
894 IWL_MAX_SCAN_SIZE - sizeof(*scan)); 901 scan_cmd_size - sizeof(*scan));
895 break; 902 break;
896 default: 903 default:
897 BUG(); 904 BUG();