aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/wl12xx/wl1251_main.c
diff options
context:
space:
mode:
authorKalle Valo <kalle.valo@nokia.com>2010-01-05 13:16:51 -0500
committerJohn W. Linville <linville@tuxdriver.com>2010-01-12 13:51:26 -0500
commit3a98c30f3e8bb1f32b5bcb74a39647b3670de275 (patch)
treef24eb2e787dab86f3c90ffe4d0f5e92e6fff2d59 /drivers/net/wireless/wl12xx/wl1251_main.c
parent7c12ce8b854df346388ea56d684784e3484012cf (diff)
wl1251: cleanup scanning code
The current scanning code wasn't following the preferred style. Move code related to scan and trigger scan to commans to wl1251_cmd.c. Because there's now less code in wl1251_hw_scan(), the function can be now merged with wl1251_op_hw_scan(). Signed-off-by: Kalle Valo <kalle.valo@nokia.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
Diffstat (limited to 'drivers/net/wireless/wl12xx/wl1251_main.c')
-rw-r--r--drivers/net/wireless/wl12xx/wl1251_main.c125
1 files changed, 24 insertions, 101 deletions
diff --git a/drivers/net/wireless/wl12xx/wl1251_main.c b/drivers/net/wireless/wl12xx/wl1251_main.c
index 6cce86462fa..e038707294a 100644
--- a/drivers/net/wireless/wl12xx/wl1251_main.c
+++ b/drivers/net/wireless/wl12xx/wl1251_main.c
@@ -903,111 +903,13 @@ static int wl1251_build_probe_req(struct wl1251 *wl, u8 *ssid, size_t ssid_len)
903 size); 903 size);
904} 904}
905 905
906static int wl1251_hw_scan(struct wl1251 *wl, u8 *ssid, size_t len,
907 u8 active_scan, u8 high_prio, u8 num_channels,
908 u8 probe_requests)
909{
910 struct wl1251_cmd_trigger_scan_to *trigger = NULL;
911 struct cmd_scan *params = NULL;
912 int i, ret;
913 u16 scan_options = 0;
914
915 if (wl->scanning)
916 return -EINVAL;
917
918 params = kzalloc(sizeof(*params), GFP_KERNEL);
919 if (!params)
920 return -ENOMEM;
921
922 params->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD);
923 params->params.rx_filter_options =
924 cpu_to_le32(CFG_RX_PRSP_EN | CFG_RX_MGMT_EN | CFG_RX_BCN_EN);
925
926 /* High priority scan */
927 if (!active_scan)
928 scan_options |= SCAN_PASSIVE;
929 if (high_prio)
930 scan_options |= SCAN_PRIORITY_HIGH;
931 params->params.scan_options = scan_options;
932
933 params->params.num_channels = num_channels;
934 params->params.num_probe_requests = probe_requests;
935 params->params.tx_rate = cpu_to_le16(1 << 1); /* 2 Mbps */
936 params->params.tid_trigger = 0;
937
938 for (i = 0; i < num_channels; i++) {
939 params->channels[i].min_duration = cpu_to_le32(30000);
940 params->channels[i].max_duration = cpu_to_le32(60000);
941 memset(&params->channels[i].bssid_lsb, 0xff, 4);
942 memset(&params->channels[i].bssid_msb, 0xff, 2);
943 params->channels[i].early_termination = 0;
944 params->channels[i].tx_power_att = 0;
945 params->channels[i].channel = i + 1;
946 memset(params->channels[i].pad, 0, 3);
947 }
948
949 for (i = num_channels; i < SCAN_MAX_NUM_OF_CHANNELS; i++)
950 memset(&params->channels[i], 0,
951 sizeof(struct basic_scan_channel_parameters));
952
953 if (len && ssid) {
954 params->params.ssid_len = len;
955 memcpy(params->params.ssid, ssid, len);
956 } else {
957 params->params.ssid_len = 0;
958 memset(params->params.ssid, 0, 32);
959 }
960
961 ret = wl1251_build_probe_req(wl, ssid, len);
962 if (ret < 0) {
963 wl1251_error("PROBE request template failed");
964 goto out;
965 }
966
967 trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
968 if (!trigger)
969 goto out;
970
971 trigger->timeout = 0;
972
973 ret = wl1251_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger,
974 sizeof(*trigger));
975 if (ret < 0) {
976 wl1251_error("trigger scan to failed for hw scan");
977 goto out;
978 }
979
980 wl1251_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params));
981
982 wl->scanning = true;
983
984 ret = wl1251_cmd_send(wl, CMD_SCAN, params, sizeof(*params));
985 if (ret < 0)
986 wl1251_error("SCAN failed");
987
988 wl1251_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params));
989
990 if (params->header.status != CMD_STATUS_SUCCESS) {
991 wl1251_error("TEST command answer error: %d",
992 params->header.status);
993 wl->scanning = false;
994 ret = -EIO;
995 goto out;
996 }
997
998out:
999 kfree(params);
1000 return ret;
1001
1002}
1003
1004static int wl1251_op_hw_scan(struct ieee80211_hw *hw, 906static int wl1251_op_hw_scan(struct ieee80211_hw *hw,
1005 struct cfg80211_scan_request *req) 907 struct cfg80211_scan_request *req)
1006{ 908{
1007 struct wl1251 *wl = hw->priv; 909 struct wl1251 *wl = hw->priv;
1008 int ret;
1009 u8 *ssid = NULL;
1010 size_t ssid_len = 0; 910 size_t ssid_len = 0;
911 u8 *ssid = NULL;
912 int ret;
1011 913
1012 wl1251_debug(DEBUG_MAC80211, "mac80211 hw scan"); 914 wl1251_debug(DEBUG_MAC80211, "mac80211 hw scan");
1013 915
@@ -1018,12 +920,33 @@ static int wl1251_op_hw_scan(struct ieee80211_hw *hw,
1018 920
1019 mutex_lock(&wl->mutex); 921 mutex_lock(&wl->mutex);
1020 922
923 if (wl->scanning) {
924 wl1251_debug(DEBUG_SCAN, "scan already in progress");
925 ret = -EINVAL;
926 goto out;
927 }
928
1021 ret = wl1251_ps_elp_wakeup(wl); 929 ret = wl1251_ps_elp_wakeup(wl);
1022 if (ret < 0) 930 if (ret < 0)
1023 goto out; 931 goto out;
1024 932
1025 ret = wl1251_hw_scan(hw->priv, ssid, ssid_len, 1, 0, 13, 3); 933 ret = wl1251_build_probe_req(wl, ssid, ssid_len);
934 if (ret < 0)
935 wl1251_error("probe request template build failed");
936
937 ret = wl1251_cmd_trigger_scan_to(wl, 0);
938 if (ret < 0)
939 goto out_sleep;
940
941 wl->scanning = true;
1026 942
943 ret = wl1251_cmd_scan(wl, ssid, ssid_len, 13, 3);
944 if (ret < 0) {
945 wl->scanning = false;
946 goto out_sleep;
947 }
948
949out_sleep:
1027 wl1251_ps_elp_sleep(wl); 950 wl1251_ps_elp_sleep(wl);
1028 951
1029out: 952out: