2 * Intel Wireless Multicomm 3200 WiFi driver
4 * Copyright (C) 2009 Intel Corporation. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in
14 * the documentation and/or other materials provided with the
16 * * Neither the name of Intel Corporation nor the names of its
17 * contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 * Intel Corporation <ilw@linux.intel.com>
34 * Samuel Ortiz <samuel.ortiz@intel.com>
35 * Zhu Yi <yi.zhu@intel.com>
39 #include <linux/kernel.h>
40 #include <linux/netdevice.h>
41 #include <linux/sched.h>
42 #include <linux/ieee80211.h>
43 #include <linux/wireless.h>
44 #include <linux/slab.h>
55 static struct iwm_conf def_iwm_conf = {
57 .sdio_ior_timeout = 5000,
58 .calib_map = BIT(CALIB_CFG_DC_IDX) |
59 BIT(CALIB_CFG_LO_IDX) |
60 BIT(CALIB_CFG_TX_IQ_IDX) |
61 BIT(CALIB_CFG_RX_IQ_IDX) |
62 BIT(SHILOH_PHY_CALIBRATE_BASE_BAND_CMD),
63 .expected_calib_map = BIT(PHY_CALIBRATE_DC_CMD) |
64 BIT(PHY_CALIBRATE_LO_CMD) |
65 BIT(PHY_CALIBRATE_TX_IQ_CMD) |
66 BIT(PHY_CALIBRATE_RX_IQ_CMD) |
67 BIT(SHILOH_PHY_CALIBRATE_BASE_BAND_CMD),
70 .reset_on_fatal_err = 1,
73 .mode = UMAC_MODE_BSS,
75 /* UMAC configuration */
77 .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD,
78 .rts_threshold = IEEE80211_MAX_RTS_THRESHOLD,
83 .wireless_mode = WIRELESS_MODE_11A | WIRELESS_MODE_11G |
87 .ibss_band = UMAC_BAND_2GHZ,
90 .mac_addr = {0x00, 0x02, 0xb3, 0x01, 0x02, 0x03},
93 static int modparam_reset;
94 module_param_named(reset, modparam_reset, bool, 0644);
95 MODULE_PARM_DESC(reset, "reset on firmware errors (default 0 [not reset])");
97 static int modparam_wimax_enable = 1;
98 module_param_named(wimax_enable, modparam_wimax_enable, bool, 0644);
99 MODULE_PARM_DESC(wimax_enable, "Enable wimax core (default 1 [wimax enabled])");
101 int iwm_mode_to_nl80211_iftype(int mode)
105 return NL80211_IFTYPE_STATION;
107 return NL80211_IFTYPE_ADHOC;
109 return NL80211_IFTYPE_UNSPECIFIED;
115 static void iwm_statistics_request(struct work_struct *work)
117 struct iwm_priv *iwm =
118 container_of(work, struct iwm_priv, stats_request.work);
120 iwm_send_umac_stats_req(iwm, 0);
123 static void iwm_disconnect_work(struct work_struct *work)
125 struct iwm_priv *iwm =
126 container_of(work, struct iwm_priv, disconnect.work);
128 if (iwm->umac_profile_active)
129 iwm_invalidate_mlme_profile(iwm);
131 clear_bit(IWM_STATUS_ASSOCIATED, &iwm->status);
132 iwm->umac_profile_active = 0;
133 memset(iwm->bssid, 0, ETH_ALEN);
138 wake_up_interruptible(&iwm->mlme_queue);
140 cfg80211_disconnected(iwm_to_ndev(iwm), 0, NULL, 0, GFP_KERNEL);
143 static void iwm_ct_kill_work(struct work_struct *work)
145 struct iwm_priv *iwm =
146 container_of(work, struct iwm_priv, ct_kill_delay.work);
147 struct wiphy *wiphy = iwm_to_wiphy(iwm);
149 IWM_INFO(iwm, "CT kill delay timeout\n");
151 wiphy_rfkill_set_hw_state(wiphy, false);
154 static int __iwm_up(struct iwm_priv *iwm);
155 static int __iwm_down(struct iwm_priv *iwm);
157 static void iwm_reset_worker(struct work_struct *work)
159 struct iwm_priv *iwm;
160 struct iwm_umac_profile *profile = NULL;
161 int uninitialized_var(ret), retry = 0;
163 iwm = container_of(work, struct iwm_priv, reset_worker);
166 * XXX: The iwm->mutex is introduced purely for this reset work,
167 * because the other users for iwm_up and iwm_down are only netdev
168 * ndo_open and ndo_stop which are already protected by rtnl.
169 * Please remove iwm->mutex together if iwm_reset_worker() is not
170 * required in the future.
172 if (!mutex_trylock(&iwm->mutex)) {
173 IWM_WARN(iwm, "We are in the middle of interface bringing "
174 "UP/DOWN. Skip driver resetting.\n");
178 if (iwm->umac_profile_active) {
179 profile = kmalloc(sizeof(struct iwm_umac_profile), GFP_KERNEL);
181 memcpy(profile, iwm->umac_profile, sizeof(*profile));
183 IWM_ERR(iwm, "Couldn't alloc memory for profile\n");
188 while (retry++ < 3) {
193 schedule_timeout_uninterruptible(10 * HZ);
197 IWM_WARN(iwm, "iwm_up() failed: %d\n", ret);
204 IWM_DBG_MLME(iwm, DBG, "Resend UMAC profile\n");
205 memcpy(iwm->umac_profile, profile, sizeof(*profile));
206 iwm_send_mlme_profile(iwm);
209 clear_bit(IWM_STATUS_RESETTING, &iwm->status);
212 mutex_unlock(&iwm->mutex);
215 static void iwm_auth_retry_worker(struct work_struct *work)
217 struct iwm_priv *iwm;
220 iwm = container_of(work, struct iwm_priv, auth_retry_worker);
221 if (iwm->umac_profile_active) {
222 ret = iwm_invalidate_mlme_profile(iwm);
227 iwm->umac_profile->sec.auth_type = UMAC_AUTH_TYPE_LEGACY_PSK;
229 ret = iwm_send_mlme_profile(iwm);
233 for (i = 0; i < IWM_NUM_KEYS; i++)
234 if (iwm->keys[i].key_len)
235 iwm_set_key(iwm, 0, &iwm->keys[i]);
237 iwm_set_tx_key(iwm, iwm->default_key);
242 static void iwm_watchdog(unsigned long data)
244 struct iwm_priv *iwm = (struct iwm_priv *)data;
246 IWM_WARN(iwm, "Watchdog expired: UMAC stalls!\n");
252 int iwm_priv_init(struct iwm_priv *iwm)
258 INIT_LIST_HEAD(&iwm->pending_notif);
259 init_waitqueue_head(&iwm->notif_queue);
260 init_waitqueue_head(&iwm->nonwifi_queue);
261 init_waitqueue_head(&iwm->wifi_ntfy_queue);
262 init_waitqueue_head(&iwm->mlme_queue);
263 memcpy(&iwm->conf, &def_iwm_conf, sizeof(struct iwm_conf));
264 spin_lock_init(&iwm->tx_credit.lock);
265 INIT_LIST_HEAD(&iwm->wifi_pending_cmd);
266 INIT_LIST_HEAD(&iwm->nonwifi_pending_cmd);
267 iwm->wifi_seq_num = UMAC_WIFI_SEQ_NUM_BASE;
268 iwm->nonwifi_seq_num = UMAC_NONWIFI_SEQ_NUM_BASE;
269 spin_lock_init(&iwm->cmd_lock);
271 INIT_DELAYED_WORK(&iwm->stats_request, iwm_statistics_request);
272 INIT_DELAYED_WORK(&iwm->disconnect, iwm_disconnect_work);
273 INIT_DELAYED_WORK(&iwm->ct_kill_delay, iwm_ct_kill_work);
274 INIT_WORK(&iwm->reset_worker, iwm_reset_worker);
275 INIT_WORK(&iwm->auth_retry_worker, iwm_auth_retry_worker);
276 INIT_LIST_HEAD(&iwm->bss_list);
278 skb_queue_head_init(&iwm->rx_list);
279 INIT_LIST_HEAD(&iwm->rx_tickets);
280 for (i = 0; i < IWM_RX_ID_HASH; i++)
281 INIT_LIST_HEAD(&iwm->rx_packets[i]);
283 INIT_WORK(&iwm->rx_worker, iwm_rx_worker);
285 iwm->rx_wq = create_singlethread_workqueue(KBUILD_MODNAME "_rx");
289 for (i = 0; i < IWM_TX_QUEUES; i++) {
290 INIT_WORK(&iwm->txq[i].worker, iwm_tx_worker);
291 snprintf(name, 32, KBUILD_MODNAME "_tx_%d", i);
293 iwm->txq[i].wq = create_singlethread_workqueue(name);
297 skb_queue_head_init(&iwm->txq[i].queue);
298 skb_queue_head_init(&iwm->txq[i].stopped_queue);
299 spin_lock_init(&iwm->txq[i].lock);
302 for (i = 0; i < IWM_NUM_KEYS; i++)
303 memset(&iwm->keys[i], 0, sizeof(struct iwm_key));
305 iwm->default_key = -1;
307 for (i = 0; i < IWM_STA_TABLE_NUM; i++)
308 for (j = 0; j < IWM_UMAC_TID_NR; j++) {
309 mutex_init(&iwm->sta_table[i].tid_info[j].mutex);
310 iwm->sta_table[i].tid_info[j].stopped = false;
313 init_timer(&iwm->watchdog);
314 iwm->watchdog.function = iwm_watchdog;
315 iwm->watchdog.data = (unsigned long)iwm;
316 mutex_init(&iwm->mutex);
318 iwm->last_fw_err = kzalloc(sizeof(struct iwm_fw_error_hdr),
320 if (iwm->last_fw_err == NULL)
326 void iwm_priv_deinit(struct iwm_priv *iwm)
330 for (i = 0; i < IWM_TX_QUEUES; i++)
331 destroy_workqueue(iwm->txq[i].wq);
333 destroy_workqueue(iwm->rx_wq);
334 kfree(iwm->last_fw_err);
338 * We reset all the structures, and we reset the UMAC.
339 * After calling this routine, you're expected to reload
342 void iwm_reset(struct iwm_priv *iwm)
344 struct iwm_notif *notif, *next;
346 if (test_bit(IWM_STATUS_READY, &iwm->status))
347 iwm_target_reset(iwm);
349 if (test_bit(IWM_STATUS_RESETTING, &iwm->status)) {
351 set_bit(IWM_STATUS_RESETTING, &iwm->status);
356 list_for_each_entry_safe(notif, next, &iwm->pending_notif, pending) {
357 list_del(¬if->pending);
364 flush_workqueue(iwm->rx_wq);
369 void iwm_resetting(struct iwm_priv *iwm)
371 set_bit(IWM_STATUS_RESETTING, &iwm->status);
373 schedule_work(&iwm->reset_worker);
379 * We're faced with the following issue: Any host command can
380 * have an answer or not, and if there's an answer to expect,
381 * it can be treated synchronously or asynchronously.
382 * To work around the synchronous answer case, we implemented
383 * our notification mechanism.
384 * When a code path needs to wait for a command response
385 * synchronously, it calls notif_handle(), which waits for the
386 * right notification to show up, and then process it. Before
387 * starting to wait, it registered as a waiter for this specific
388 * answer (by toggling a bit in on of the handler_map), so that
389 * the rx code knows that it needs to send a notification to the
390 * waiting processes. It does so by calling iwm_notif_send(),
391 * which adds the notification to the pending notifications list,
392 * and then wakes the waiting processes up.
394 int iwm_notif_send(struct iwm_priv *iwm, struct iwm_wifi_cmd *cmd,
395 u8 cmd_id, u8 source, u8 *buf, unsigned long buf_size)
397 struct iwm_notif *notif;
399 notif = kzalloc(sizeof(struct iwm_notif), GFP_KERNEL);
401 IWM_ERR(iwm, "Couldn't alloc memory for notification\n");
405 INIT_LIST_HEAD(¬if->pending);
407 notif->cmd_id = cmd_id;
409 notif->buf = kzalloc(buf_size, GFP_KERNEL);
411 IWM_ERR(iwm, "Couldn't alloc notification buffer\n");
415 notif->buf_size = buf_size;
416 memcpy(notif->buf, buf, buf_size);
417 list_add_tail(¬if->pending, &iwm->pending_notif);
419 wake_up_interruptible(&iwm->notif_queue);
424 static struct iwm_notif *iwm_notif_find(struct iwm_priv *iwm, u32 cmd,
427 struct iwm_notif *notif, *next;
429 list_for_each_entry_safe(notif, next, &iwm->pending_notif, pending) {
430 if ((notif->cmd_id == cmd) && (notif->src == source)) {
431 list_del(¬if->pending);
439 static struct iwm_notif *iwm_notif_wait(struct iwm_priv *iwm, u32 cmd,
440 u8 source, long timeout)
443 struct iwm_notif *notif;
444 unsigned long *map = NULL;
448 map = &iwm->lmac_handler_map[0];
451 map = &iwm->umac_handler_map[0];
454 map = &iwm->udma_handler_map[0];
460 ret = wait_event_interruptible_timeout(iwm->notif_queue,
461 ((notif = iwm_notif_find(iwm, cmd, source)) != NULL),
471 int iwm_notif_handle(struct iwm_priv *iwm, u32 cmd, u8 source, long timeout)
474 struct iwm_notif *notif;
476 notif = iwm_notif_wait(iwm, cmd, source, timeout);
480 ret = iwm_rx_handle_resp(iwm, notif->buf, notif->buf_size, notif->cmd);
487 static int iwm_config_boot_params(struct iwm_priv *iwm)
489 struct iwm_udma_nonwifi_cmd target_cmd;
492 /* check Wimax is off and config debug monitor */
493 if (!modparam_wimax_enable) {
495 u32 addr1 = 0x606BE258;
499 u32 addr2 = 0x606BE100;
502 u32 addr3 = 0x606BEC00;
505 target_cmd.handle_by_hw = 0;
508 target_cmd.opcode = UMAC_HDI_OUT_OPCODE_WRITE;
509 target_cmd.addr = cpu_to_le32(addr1);
510 target_cmd.op1_sz = cpu_to_le32(sizeof(u32));
513 ret = iwm_hal_send_target_cmd(iwm, &target_cmd, &data1);
515 IWM_ERR(iwm, "iwm_hal_send_target_cmd failed\n");
519 target_cmd.opcode = UMAC_HDI_OUT_OPCODE_READ_MODIFY_WRITE;
520 target_cmd.addr = cpu_to_le32(addr2);
521 target_cmd.op1_sz = cpu_to_le32(data2_set);
522 target_cmd.op2 = cpu_to_le32(data2_clr);
524 ret = iwm_hal_send_target_cmd(iwm, &target_cmd, &data1);
526 IWM_ERR(iwm, "iwm_hal_send_target_cmd failed\n");
530 target_cmd.opcode = UMAC_HDI_OUT_OPCODE_WRITE;
531 target_cmd.addr = cpu_to_le32(addr3);
532 target_cmd.op1_sz = cpu_to_le32(sizeof(u32));
535 ret = iwm_hal_send_target_cmd(iwm, &target_cmd, &data3);
537 IWM_ERR(iwm, "iwm_hal_send_target_cmd failed\n");
545 void iwm_init_default_profile(struct iwm_priv *iwm,
546 struct iwm_umac_profile *profile)
548 memset(profile, 0, sizeof(struct iwm_umac_profile));
550 profile->sec.auth_type = UMAC_AUTH_TYPE_OPEN;
551 profile->sec.flags = UMAC_SEC_FLG_LEGACY_PROFILE;
552 profile->sec.ucast_cipher = UMAC_CIPHER_TYPE_NONE;
553 profile->sec.mcast_cipher = UMAC_CIPHER_TYPE_NONE;
555 if (iwm->conf.enable_qos)
556 profile->flags |= cpu_to_le16(UMAC_PROFILE_QOS_ALLOWED);
558 profile->wireless_mode = iwm->conf.wireless_mode;
559 profile->mode = cpu_to_le32(iwm->conf.mode);
561 profile->ibss.atim = 0;
562 profile->ibss.beacon_interval = 100;
563 profile->ibss.join_only = 0;
564 profile->ibss.band = iwm->conf.ibss_band;
565 profile->ibss.channel = iwm->conf.ibss_channel;
568 void iwm_link_on(struct iwm_priv *iwm)
570 netif_carrier_on(iwm_to_ndev(iwm));
571 netif_tx_wake_all_queues(iwm_to_ndev(iwm));
573 iwm_send_umac_stats_req(iwm, 0);
576 void iwm_link_off(struct iwm_priv *iwm)
578 struct iw_statistics *wstats = &iwm->wstats;
581 netif_tx_stop_all_queues(iwm_to_ndev(iwm));
582 netif_carrier_off(iwm_to_ndev(iwm));
584 for (i = 0; i < IWM_TX_QUEUES; i++) {
585 skb_queue_purge(&iwm->txq[i].queue);
586 skb_queue_purge(&iwm->txq[i].stopped_queue);
588 iwm->txq[i].concat_count = 0;
589 iwm->txq[i].concat_ptr = iwm->txq[i].concat_buf;
591 flush_workqueue(iwm->txq[i].wq);
596 cancel_delayed_work_sync(&iwm->stats_request);
597 memset(wstats, 0, sizeof(struct iw_statistics));
598 wstats->qual.updated = IW_QUAL_ALL_INVALID;
605 iwm->resp_ie_len = 0;
607 del_timer_sync(&iwm->watchdog);
610 static void iwm_bss_list_clean(struct iwm_priv *iwm)
612 struct iwm_bss_info *bss, *next;
614 list_for_each_entry_safe(bss, next, &iwm->bss_list, node) {
615 list_del(&bss->node);
621 static int iwm_channels_init(struct iwm_priv *iwm)
625 ret = iwm_send_umac_channel_list(iwm);
627 IWM_ERR(iwm, "Send channel list failed\n");
631 ret = iwm_notif_handle(iwm, UMAC_CMD_OPCODE_GET_CHAN_INFO_LIST,
632 IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
634 IWM_ERR(iwm, "Didn't get a channel list notification\n");
641 static int __iwm_up(struct iwm_priv *iwm)
644 struct iwm_notif *notif_reboot, *notif_ack = NULL;
645 struct wiphy *wiphy = iwm_to_wiphy(iwm);
648 ret = iwm_bus_enable(iwm);
650 IWM_ERR(iwm, "Couldn't enable function\n");
654 iwm_rx_setup_handlers(iwm);
656 /* Wait for initial BARKER_REBOOT from hardware */
657 notif_reboot = iwm_notif_wait(iwm, IWM_BARKER_REBOOT_NOTIFICATION,
658 IWM_SRC_UDMA, 2 * HZ);
660 IWM_ERR(iwm, "Wait for REBOOT_BARKER timeout\n");
664 /* We send the barker back */
665 ret = iwm_bus_send_chunk(iwm, notif_reboot->buf, 16);
667 IWM_ERR(iwm, "REBOOT barker response failed\n");
672 kfree(notif_reboot->buf);
675 /* Wait for ACK_BARKER from hardware */
676 notif_ack = iwm_notif_wait(iwm, IWM_ACK_BARKER_NOTIFICATION,
677 IWM_SRC_UDMA, 2 * HZ);
679 IWM_ERR(iwm, "Wait for ACK_BARKER timeout\n");
683 kfree(notif_ack->buf);
686 /* We start to config static boot parameters */
687 ret = iwm_config_boot_params(iwm);
689 IWM_ERR(iwm, "Config boot parameters failed\n");
693 ret = iwm_read_mac(iwm, iwm_to_ndev(iwm)->dev_addr);
695 IWM_ERR(iwm, "MAC reading failed\n");
698 memcpy(iwm_to_ndev(iwm)->perm_addr, iwm_to_ndev(iwm)->dev_addr,
701 /* We can load the FWs */
702 ret = iwm_load_fw(iwm);
704 IWM_ERR(iwm, "FW loading failed\n");
708 ret = iwm_eeprom_fat_channels(iwm);
710 IWM_ERR(iwm, "Couldnt read HT channels EEPROM entries\n");
715 * Read our SKU capabilities.
716 * If it's valid, we AND the configured wireless mode with the
717 * device EEPROM value as the current profile wireless mode.
719 wireless_mode = iwm_eeprom_wireless_mode(iwm);
721 iwm->conf.wireless_mode &= wireless_mode;
722 if (iwm->umac_profile)
723 iwm->umac_profile->wireless_mode =
724 iwm->conf.wireless_mode;
726 IWM_ERR(iwm, "Wrong SKU capabilities: 0x%x\n",
727 *((u16 *)iwm_eeprom_access(iwm, IWM_EEPROM_SKU_CAP)));
729 snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "L%s_U%s",
730 iwm->lmac_version, iwm->umac_version);
732 /* We configure the UMAC and enable the wifi module */
733 ret = iwm_send_umac_config(iwm,
734 cpu_to_le32(UMAC_RST_CTRL_FLG_WIFI_CORE_EN) |
735 cpu_to_le32(UMAC_RST_CTRL_FLG_WIFI_LINK_EN) |
736 cpu_to_le32(UMAC_RST_CTRL_FLG_WIFI_MLME_EN));
738 IWM_ERR(iwm, "UMAC config failed\n");
742 ret = iwm_notif_handle(iwm, UMAC_NOTIFY_OPCODE_WIFI_CORE_STATUS,
743 IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
745 IWM_ERR(iwm, "Didn't get a wifi core status notification\n");
749 if (iwm->core_enabled != (UMAC_NTFY_WIFI_CORE_STATUS_LINK_EN |
750 UMAC_NTFY_WIFI_CORE_STATUS_MLME_EN)) {
751 IWM_DBG_BOOT(iwm, DBG, "Not all cores enabled:0x%x\n",
753 ret = iwm_notif_handle(iwm, UMAC_NOTIFY_OPCODE_WIFI_CORE_STATUS,
754 IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
756 IWM_ERR(iwm, "Didn't get a core status notification\n");
760 if (iwm->core_enabled != (UMAC_NTFY_WIFI_CORE_STATUS_LINK_EN |
761 UMAC_NTFY_WIFI_CORE_STATUS_MLME_EN)) {
762 IWM_ERR(iwm, "Not all cores enabled: 0x%x\n",
766 IWM_INFO(iwm, "All cores enabled\n");
770 ret = iwm_channels_init(iwm);
772 IWM_ERR(iwm, "Couldn't init channels\n");
776 /* Set the READY bit to indicate interface is brought up successfully */
777 set_bit(IWM_STATUS_READY, &iwm->status);
782 iwm_eeprom_exit(iwm);
785 ret = iwm_bus_disable(iwm);
787 IWM_ERR(iwm, "Couldn't disable function\n");
792 int iwm_up(struct iwm_priv *iwm)
796 mutex_lock(&iwm->mutex);
798 mutex_unlock(&iwm->mutex);
803 static int __iwm_down(struct iwm_priv *iwm)
807 /* The interface is already down */
808 if (!test_bit(IWM_STATUS_READY, &iwm->status))
811 if (iwm->scan_request) {
812 cfg80211_scan_done(iwm->scan_request, true);
813 iwm->scan_request = NULL;
816 clear_bit(IWM_STATUS_READY, &iwm->status);
818 iwm_eeprom_exit(iwm);
819 iwm_bss_list_clean(iwm);
820 iwm_init_default_profile(iwm, iwm->umac_profile);
821 iwm->umac_profile_active = false;
822 iwm->default_key = -1;
823 iwm->core_enabled = 0;
825 ret = iwm_bus_disable(iwm);
827 IWM_ERR(iwm, "Couldn't disable function\n");
834 int iwm_down(struct iwm_priv *iwm)
838 mutex_lock(&iwm->mutex);
839 ret = __iwm_down(iwm);
840 mutex_unlock(&iwm->mutex);