scan.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606
  1. /*
  2. * This file is part of wl1271
  3. *
  4. * Copyright (C) 2009-2010 Nokia Corporation
  5. *
  6. * Contact: Luciano Coelho <luciano.coelho@nokia.com>
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * version 2 as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  20. * 02110-1301 USA
  21. *
  22. */
  23. #include <linux/ieee80211.h>
  24. #include "wl12xx.h"
  25. #include "cmd.h"
  26. #include "scan.h"
  27. #include "acx.h"
  28. #include "ps.h"
  29. void wl1271_scan_complete_work(struct work_struct *work)
  30. {
  31. struct delayed_work *dwork;
  32. struct wl1271 *wl;
  33. dwork = container_of(work, struct delayed_work, work);
  34. wl = container_of(dwork, struct wl1271, scan_complete_work);
  35. wl1271_debug(DEBUG_SCAN, "Scanning complete");
  36. mutex_lock(&wl->mutex);
  37. if (wl->state == WL1271_STATE_OFF)
  38. goto out;
  39. if (wl->scan.state == WL1271_SCAN_STATE_IDLE)
  40. goto out;
  41. wl->scan.state = WL1271_SCAN_STATE_IDLE;
  42. memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
  43. wl->scan.req = NULL;
  44. ieee80211_scan_completed(wl->hw, false);
  45. /* restore hardware connection monitoring template */
  46. if (test_bit(WL1271_FLAG_STA_ASSOCIATED, &wl->flags)) {
  47. if (wl1271_ps_elp_wakeup(wl) == 0) {
  48. wl1271_cmd_build_ap_probe_req(wl, wl->probereq);
  49. wl1271_ps_elp_sleep(wl);
  50. }
  51. }
  52. if (wl->scan.failed) {
  53. wl1271_info("Scan completed due to error.");
  54. wl12xx_queue_recovery_work(wl);
  55. }
  56. out:
  57. mutex_unlock(&wl->mutex);
  58. }
  59. static int wl1271_get_scan_channels(struct wl1271 *wl,
  60. struct cfg80211_scan_request *req,
  61. struct basic_scan_channel_params *channels,
  62. enum ieee80211_band band, bool passive)
  63. {
  64. struct conf_scan_settings *c = &wl->conf.scan;
  65. int i, j;
  66. u32 flags;
  67. for (i = 0, j = 0;
  68. i < req->n_channels && j < WL1271_SCAN_MAX_CHANNELS;
  69. i++) {
  70. flags = req->channels[i]->flags;
  71. if (!test_bit(i, wl->scan.scanned_ch) &&
  72. !(flags & IEEE80211_CHAN_DISABLED) &&
  73. ((!!(flags & IEEE80211_CHAN_PASSIVE_SCAN)) == passive) &&
  74. (req->channels[i]->band == band)) {
  75. wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
  76. req->channels[i]->band,
  77. req->channels[i]->center_freq);
  78. wl1271_debug(DEBUG_SCAN, "hw_value %d, flags %X",
  79. req->channels[i]->hw_value,
  80. req->channels[i]->flags);
  81. wl1271_debug(DEBUG_SCAN,
  82. "max_antenna_gain %d, max_power %d",
  83. req->channels[i]->max_antenna_gain,
  84. req->channels[i]->max_power);
  85. wl1271_debug(DEBUG_SCAN, "beacon_found %d",
  86. req->channels[i]->beacon_found);
  87. if (!passive) {
  88. channels[j].min_duration =
  89. cpu_to_le32(c->min_dwell_time_active);
  90. channels[j].max_duration =
  91. cpu_to_le32(c->max_dwell_time_active);
  92. } else {
  93. channels[j].min_duration =
  94. cpu_to_le32(c->min_dwell_time_passive);
  95. channels[j].max_duration =
  96. cpu_to_le32(c->max_dwell_time_passive);
  97. }
  98. channels[j].early_termination = 0;
  99. channels[j].tx_power_att = req->channels[i]->max_power;
  100. channels[j].channel = req->channels[i]->hw_value;
  101. memset(&channels[j].bssid_lsb, 0xff, 4);
  102. memset(&channels[j].bssid_msb, 0xff, 2);
  103. /* Mark the channels we already used */
  104. set_bit(i, wl->scan.scanned_ch);
  105. j++;
  106. }
  107. }
  108. return j;
  109. }
  110. #define WL1271_NOTHING_TO_SCAN 1
  111. static int wl1271_scan_send(struct wl1271 *wl, enum ieee80211_band band,
  112. bool passive, u32 basic_rate)
  113. {
  114. struct wl1271_cmd_scan *cmd;
  115. struct wl1271_cmd_trigger_scan_to *trigger;
  116. int ret;
  117. u16 scan_options = 0;
  118. cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
  119. trigger = kzalloc(sizeof(*trigger), GFP_KERNEL);
  120. if (!cmd || !trigger) {
  121. ret = -ENOMEM;
  122. goto out;
  123. }
  124. /* We always use high priority scans */
  125. scan_options = WL1271_SCAN_OPT_PRIORITY_HIGH;
  126. /* No SSIDs means that we have a forced passive scan */
  127. if (passive || wl->scan.req->n_ssids == 0)
  128. scan_options |= WL1271_SCAN_OPT_PASSIVE;
  129. cmd->params.scan_options = cpu_to_le16(scan_options);
  130. cmd->params.n_ch = wl1271_get_scan_channels(wl, wl->scan.req,
  131. cmd->channels,
  132. band, passive);
  133. if (cmd->params.n_ch == 0) {
  134. ret = WL1271_NOTHING_TO_SCAN;
  135. goto out;
  136. }
  137. cmd->params.tx_rate = cpu_to_le32(basic_rate);
  138. cmd->params.rx_config_options = cpu_to_le32(CFG_RX_ALL_GOOD);
  139. cmd->params.rx_filter_options =
  140. cpu_to_le32(CFG_RX_PRSP_EN | CFG_RX_MGMT_EN | CFG_RX_BCN_EN);
  141. cmd->params.n_probe_reqs = wl->conf.scan.num_probe_reqs;
  142. cmd->params.tx_rate = cpu_to_le32(basic_rate);
  143. cmd->params.tid_trigger = 0;
  144. cmd->params.scan_tag = WL1271_SCAN_DEFAULT_TAG;
  145. if (band == IEEE80211_BAND_2GHZ)
  146. cmd->params.band = WL1271_SCAN_BAND_2_4_GHZ;
  147. else
  148. cmd->params.band = WL1271_SCAN_BAND_5_GHZ;
  149. if (wl->scan.ssid_len && wl->scan.ssid) {
  150. cmd->params.ssid_len = wl->scan.ssid_len;
  151. memcpy(cmd->params.ssid, wl->scan.ssid, wl->scan.ssid_len);
  152. }
  153. ret = wl1271_cmd_build_probe_req(wl, wl->scan.ssid, wl->scan.ssid_len,
  154. wl->scan.req->ie, wl->scan.req->ie_len,
  155. band);
  156. if (ret < 0) {
  157. wl1271_error("PROBE request template failed");
  158. goto out;
  159. }
  160. /* disable the timeout */
  161. trigger->timeout = 0;
  162. ret = wl1271_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger,
  163. sizeof(*trigger), 0);
  164. if (ret < 0) {
  165. wl1271_error("trigger scan to failed for hw scan");
  166. goto out;
  167. }
  168. wl1271_dump(DEBUG_SCAN, "SCAN: ", cmd, sizeof(*cmd));
  169. ret = wl1271_cmd_send(wl, CMD_SCAN, cmd, sizeof(*cmd), 0);
  170. if (ret < 0) {
  171. wl1271_error("SCAN failed");
  172. goto out;
  173. }
  174. out:
  175. kfree(cmd);
  176. kfree(trigger);
  177. return ret;
  178. }
  179. void wl1271_scan_stm(struct wl1271 *wl)
  180. {
  181. int ret = 0;
  182. switch (wl->scan.state) {
  183. case WL1271_SCAN_STATE_IDLE:
  184. break;
  185. case WL1271_SCAN_STATE_2GHZ_ACTIVE:
  186. ret = wl1271_scan_send(wl, IEEE80211_BAND_2GHZ, false,
  187. wl->conf.tx.basic_rate);
  188. if (ret == WL1271_NOTHING_TO_SCAN) {
  189. wl->scan.state = WL1271_SCAN_STATE_2GHZ_PASSIVE;
  190. wl1271_scan_stm(wl);
  191. }
  192. break;
  193. case WL1271_SCAN_STATE_2GHZ_PASSIVE:
  194. ret = wl1271_scan_send(wl, IEEE80211_BAND_2GHZ, true,
  195. wl->conf.tx.basic_rate);
  196. if (ret == WL1271_NOTHING_TO_SCAN) {
  197. if (wl->enable_11a)
  198. wl->scan.state = WL1271_SCAN_STATE_5GHZ_ACTIVE;
  199. else
  200. wl->scan.state = WL1271_SCAN_STATE_DONE;
  201. wl1271_scan_stm(wl);
  202. }
  203. break;
  204. case WL1271_SCAN_STATE_5GHZ_ACTIVE:
  205. ret = wl1271_scan_send(wl, IEEE80211_BAND_5GHZ, false,
  206. wl->conf.tx.basic_rate_5);
  207. if (ret == WL1271_NOTHING_TO_SCAN) {
  208. wl->scan.state = WL1271_SCAN_STATE_5GHZ_PASSIVE;
  209. wl1271_scan_stm(wl);
  210. }
  211. break;
  212. case WL1271_SCAN_STATE_5GHZ_PASSIVE:
  213. ret = wl1271_scan_send(wl, IEEE80211_BAND_5GHZ, true,
  214. wl->conf.tx.basic_rate_5);
  215. if (ret == WL1271_NOTHING_TO_SCAN) {
  216. wl->scan.state = WL1271_SCAN_STATE_DONE;
  217. wl1271_scan_stm(wl);
  218. }
  219. break;
  220. case WL1271_SCAN_STATE_DONE:
  221. wl->scan.failed = false;
  222. cancel_delayed_work(&wl->scan_complete_work);
  223. ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work,
  224. msecs_to_jiffies(0));
  225. break;
  226. default:
  227. wl1271_error("invalid scan state");
  228. break;
  229. }
  230. if (ret < 0) {
  231. cancel_delayed_work(&wl->scan_complete_work);
  232. ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work,
  233. msecs_to_jiffies(0));
  234. }
  235. }
  236. int wl1271_scan(struct wl1271 *wl, const u8 *ssid, size_t ssid_len,
  237. struct cfg80211_scan_request *req)
  238. {
  239. /*
  240. * cfg80211 should guarantee that we don't get more channels
  241. * than what we have registered.
  242. */
  243. BUG_ON(req->n_channels > WL1271_MAX_CHANNELS);
  244. if (wl->scan.state != WL1271_SCAN_STATE_IDLE)
  245. return -EBUSY;
  246. wl->scan.state = WL1271_SCAN_STATE_2GHZ_ACTIVE;
  247. if (ssid_len && ssid) {
  248. wl->scan.ssid_len = ssid_len;
  249. memcpy(wl->scan.ssid, ssid, ssid_len);
  250. } else {
  251. wl->scan.ssid_len = 0;
  252. }
  253. wl->scan.req = req;
  254. memset(wl->scan.scanned_ch, 0, sizeof(wl->scan.scanned_ch));
  255. /* we assume failure so that timeout scenarios are handled correctly */
  256. wl->scan.failed = true;
  257. ieee80211_queue_delayed_work(wl->hw, &wl->scan_complete_work,
  258. msecs_to_jiffies(WL1271_SCAN_TIMEOUT));
  259. wl1271_scan_stm(wl);
  260. return 0;
  261. }
  262. int wl1271_scan_stop(struct wl1271 *wl)
  263. {
  264. struct wl1271_cmd_header *cmd = NULL;
  265. int ret = 0;
  266. if (WARN_ON(wl->scan.state == WL1271_SCAN_STATE_IDLE))
  267. return -EINVAL;
  268. wl1271_debug(DEBUG_CMD, "cmd scan stop");
  269. cmd = kzalloc(sizeof(*cmd), GFP_KERNEL);
  270. if (!cmd) {
  271. ret = -ENOMEM;
  272. goto out;
  273. }
  274. ret = wl1271_cmd_send(wl, CMD_STOP_SCAN, cmd,
  275. sizeof(*cmd), 0);
  276. if (ret < 0) {
  277. wl1271_error("cmd stop_scan failed");
  278. goto out;
  279. }
  280. out:
  281. kfree(cmd);
  282. return ret;
  283. }
  284. static int
  285. wl1271_scan_get_sched_scan_channels(struct wl1271 *wl,
  286. struct cfg80211_sched_scan_request *req,
  287. struct conn_scan_ch_params *channels,
  288. u32 band, bool radar, bool passive,
  289. int start, int max_channels)
  290. {
  291. struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
  292. int i, j;
  293. u32 flags;
  294. bool force_passive = !req->n_ssids;
  295. for (i = 0, j = start;
  296. i < req->n_channels && j < max_channels;
  297. i++) {
  298. flags = req->channels[i]->flags;
  299. if (force_passive)
  300. flags |= IEEE80211_CHAN_PASSIVE_SCAN;
  301. if ((req->channels[i]->band == band) &&
  302. !(flags & IEEE80211_CHAN_DISABLED) &&
  303. (!!(flags & IEEE80211_CHAN_RADAR) == radar) &&
  304. /* if radar is set, we ignore the passive flag */
  305. (radar ||
  306. !!(flags & IEEE80211_CHAN_PASSIVE_SCAN) == passive)) {
  307. wl1271_debug(DEBUG_SCAN, "band %d, center_freq %d ",
  308. req->channels[i]->band,
  309. req->channels[i]->center_freq);
  310. wl1271_debug(DEBUG_SCAN, "hw_value %d, flags %X",
  311. req->channels[i]->hw_value,
  312. req->channels[i]->flags);
  313. wl1271_debug(DEBUG_SCAN, "max_power %d",
  314. req->channels[i]->max_power);
  315. if (flags & IEEE80211_CHAN_RADAR) {
  316. channels[j].flags |= SCAN_CHANNEL_FLAGS_DFS;
  317. channels[j].passive_duration =
  318. cpu_to_le16(c->dwell_time_dfs);
  319. }
  320. else if (flags & IEEE80211_CHAN_PASSIVE_SCAN) {
  321. channels[j].passive_duration =
  322. cpu_to_le16(c->dwell_time_passive);
  323. } else {
  324. channels[j].min_duration =
  325. cpu_to_le16(c->min_dwell_time_active);
  326. channels[j].max_duration =
  327. cpu_to_le16(c->max_dwell_time_active);
  328. }
  329. channels[j].tx_power_att = req->channels[i]->max_power;
  330. channels[j].channel = req->channels[i]->hw_value;
  331. j++;
  332. }
  333. }
  334. return j - start;
  335. }
  336. static bool
  337. wl1271_scan_sched_scan_channels(struct wl1271 *wl,
  338. struct cfg80211_sched_scan_request *req,
  339. struct wl1271_cmd_sched_scan_config *cfg)
  340. {
  341. cfg->passive[0] =
  342. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
  343. IEEE80211_BAND_2GHZ,
  344. false, true, 0,
  345. MAX_CHANNELS_2GHZ);
  346. cfg->active[0] =
  347. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_2,
  348. IEEE80211_BAND_2GHZ,
  349. false, false,
  350. cfg->passive[0],
  351. MAX_CHANNELS_2GHZ);
  352. cfg->passive[1] =
  353. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
  354. IEEE80211_BAND_5GHZ,
  355. false, true, 0,
  356. MAX_CHANNELS_5GHZ);
  357. cfg->dfs =
  358. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
  359. IEEE80211_BAND_5GHZ,
  360. true, true,
  361. cfg->passive[1],
  362. MAX_CHANNELS_5GHZ);
  363. cfg->active[1] =
  364. wl1271_scan_get_sched_scan_channels(wl, req, cfg->channels_5,
  365. IEEE80211_BAND_5GHZ,
  366. false, false,
  367. cfg->passive[1] + cfg->dfs,
  368. MAX_CHANNELS_5GHZ);
  369. /* 802.11j channels are not supported yet */
  370. cfg->passive[2] = 0;
  371. cfg->active[2] = 0;
  372. wl1271_debug(DEBUG_SCAN, " 2.4GHz: active %d passive %d",
  373. cfg->active[0], cfg->passive[0]);
  374. wl1271_debug(DEBUG_SCAN, " 5GHz: active %d passive %d",
  375. cfg->active[1], cfg->passive[1]);
  376. wl1271_debug(DEBUG_SCAN, " DFS: %d", cfg->dfs);
  377. return cfg->passive[0] || cfg->active[0] ||
  378. cfg->passive[1] || cfg->active[1] || cfg->dfs ||
  379. cfg->passive[2] || cfg->active[2];
  380. }
  381. int wl1271_scan_sched_scan_config(struct wl1271 *wl,
  382. struct cfg80211_sched_scan_request *req,
  383. struct ieee80211_sched_scan_ies *ies)
  384. {
  385. struct wl1271_cmd_sched_scan_config *cfg = NULL;
  386. struct conf_sched_scan_settings *c = &wl->conf.sched_scan;
  387. int i, ret;
  388. bool force_passive = !req->n_ssids;
  389. wl1271_debug(DEBUG_CMD, "cmd sched_scan scan config");
  390. cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
  391. if (!cfg)
  392. return -ENOMEM;
  393. cfg->rssi_threshold = c->rssi_threshold;
  394. cfg->snr_threshold = c->snr_threshold;
  395. cfg->n_probe_reqs = c->num_probe_reqs;
  396. /* cycles set to 0 it means infinite (until manually stopped) */
  397. cfg->cycles = 0;
  398. /* report APs when at least 1 is found */
  399. cfg->report_after = 1;
  400. /* don't stop scanning automatically when something is found */
  401. cfg->terminate = 0;
  402. cfg->tag = WL1271_SCAN_DEFAULT_TAG;
  403. /* don't filter on BSS type */
  404. cfg->bss_type = SCAN_BSS_TYPE_ANY;
  405. /* currently NL80211 supports only a single interval */
  406. for (i = 0; i < SCAN_MAX_CYCLE_INTERVALS; i++)
  407. cfg->intervals[i] = cpu_to_le32(req->interval);
  408. if (!force_passive && req->ssids[0].ssid_len && req->ssids[0].ssid) {
  409. cfg->filter_type = SCAN_SSID_FILTER_SPECIFIC;
  410. cfg->ssid_len = req->ssids[0].ssid_len;
  411. memcpy(cfg->ssid, req->ssids[0].ssid,
  412. req->ssids[0].ssid_len);
  413. } else {
  414. cfg->filter_type = SCAN_SSID_FILTER_ANY;
  415. cfg->ssid_len = 0;
  416. }
  417. if (!wl1271_scan_sched_scan_channels(wl, req, cfg)) {
  418. wl1271_error("scan channel list is empty");
  419. ret = -EINVAL;
  420. goto out;
  421. }
  422. if (!force_passive && cfg->active[0]) {
  423. ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
  424. req->ssids[0].ssid_len,
  425. ies->ie[IEEE80211_BAND_2GHZ],
  426. ies->len[IEEE80211_BAND_2GHZ],
  427. IEEE80211_BAND_2GHZ);
  428. if (ret < 0) {
  429. wl1271_error("2.4GHz PROBE request template failed");
  430. goto out;
  431. }
  432. }
  433. if (!force_passive && cfg->active[1]) {
  434. ret = wl1271_cmd_build_probe_req(wl, req->ssids[0].ssid,
  435. req->ssids[0].ssid_len,
  436. ies->ie[IEEE80211_BAND_5GHZ],
  437. ies->len[IEEE80211_BAND_5GHZ],
  438. IEEE80211_BAND_5GHZ);
  439. if (ret < 0) {
  440. wl1271_error("5GHz PROBE request template failed");
  441. goto out;
  442. }
  443. }
  444. wl1271_dump(DEBUG_SCAN, "SCAN_CFG: ", cfg, sizeof(*cfg));
  445. ret = wl1271_cmd_send(wl, CMD_CONNECTION_SCAN_CFG, cfg,
  446. sizeof(*cfg), 0);
  447. if (ret < 0) {
  448. wl1271_error("SCAN configuration failed");
  449. goto out;
  450. }
  451. out:
  452. kfree(cfg);
  453. return ret;
  454. }
  455. int wl1271_scan_sched_scan_start(struct wl1271 *wl)
  456. {
  457. struct wl1271_cmd_sched_scan_start *start;
  458. int ret = 0;
  459. wl1271_debug(DEBUG_CMD, "cmd periodic scan start");
  460. if (wl->bss_type != BSS_TYPE_STA_BSS)
  461. return -EOPNOTSUPP;
  462. if (!test_bit(WL1271_FLAG_IDLE, &wl->flags))
  463. return -EBUSY;
  464. start = kzalloc(sizeof(*start), GFP_KERNEL);
  465. if (!start)
  466. return -ENOMEM;
  467. start->tag = WL1271_SCAN_DEFAULT_TAG;
  468. ret = wl1271_cmd_send(wl, CMD_START_PERIODIC_SCAN, start,
  469. sizeof(*start), 0);
  470. if (ret < 0) {
  471. wl1271_error("failed to send scan start command");
  472. goto out_free;
  473. }
  474. out_free:
  475. kfree(start);
  476. return ret;
  477. }
  478. void wl1271_scan_sched_scan_results(struct wl1271 *wl)
  479. {
  480. wl1271_debug(DEBUG_SCAN, "got periodic scan results");
  481. ieee80211_sched_scan_results(wl->hw);
  482. }
  483. void wl1271_scan_sched_scan_stop(struct wl1271 *wl)
  484. {
  485. struct wl1271_cmd_sched_scan_stop *stop;
  486. int ret = 0;
  487. wl1271_debug(DEBUG_CMD, "cmd periodic scan stop");
  488. /* FIXME: what to do if alloc'ing to stop fails? */
  489. stop = kzalloc(sizeof(*stop), GFP_KERNEL);
  490. if (!stop) {
  491. wl1271_error("failed to alloc memory to send sched scan stop");
  492. return;
  493. }
  494. stop->tag = WL1271_SCAN_DEFAULT_TAG;
  495. ret = wl1271_cmd_send(wl, CMD_STOP_PERIODIC_SCAN, stop,
  496. sizeof(*stop), 0);
  497. if (ret < 0) {
  498. wl1271_error("failed to send sched scan stop command");
  499. goto out_free;
  500. }
  501. wl->sched_scanning = false;
  502. out_free:
  503. kfree(stop);
  504. }