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>
54 static struct iwm_conf def_iwm_conf = {
56 .sdio_ior_timeout = 5000,
57 .calib_map = BIT(CALIB_CFG_DC_IDX) |
58 BIT(CALIB_CFG_LO_IDX) |
59 BIT(CALIB_CFG_TX_IQ_IDX) |
60 BIT(CALIB_CFG_RX_IQ_IDX) |
61 BIT(SHILOH_PHY_CALIBRATE_BASE_BAND_CMD),
62 .expected_calib_map = BIT(PHY_CALIBRATE_DC_CMD) |
63 BIT(PHY_CALIBRATE_LO_CMD) |
64 BIT(PHY_CALIBRATE_TX_IQ_CMD) |
65 BIT(PHY_CALIBRATE_RX_IQ_CMD) |
66 BIT(SHILOH_PHY_CALIBRATE_BASE_BAND_CMD),
69 .reset_on_fatal_err = 1,
72 .mode = UMAC_MODE_BSS,
74 /* UMAC configuration */
76 .frag_threshold = IEEE80211_MAX_FRAG_THRESHOLD,
77 .rts_threshold = IEEE80211_MAX_RTS_THRESHOLD,
82 .wireless_mode = WIRELESS_MODE_11A | WIRELESS_MODE_11G |
86 .ibss_band = UMAC_BAND_2GHZ,
89 .mac_addr = {0x00, 0x02, 0xb3, 0x01, 0x02, 0x03},
92 static int modparam_reset;
93 module_param_named(reset, modparam_reset, bool, 0644);
94 MODULE_PARM_DESC(reset, "reset on firmware errors (default 0 [not reset])");
96 static int modparam_wimax_enable = 1;
97 module_param_named(wimax_enable, modparam_wimax_enable, bool, 0644);
98 MODULE_PARM_DESC(wimax_enable, "Enable wimax core (default 1 [wimax enabled])");
100 int iwm_mode_to_nl80211_iftype(int mode)
104 return NL80211_IFTYPE_STATION;
106 return NL80211_IFTYPE_ADHOC;
108 return NL80211_IFTYPE_UNSPECIFIED;
114 static void iwm_statistics_request(struct work_struct *work)
116 struct iwm_priv *iwm =
117 container_of(work, struct iwm_priv, stats_request.work);
119 iwm_send_umac_stats_req(iwm, 0);
122 static void iwm_disconnect_work(struct work_struct *work)
124 struct iwm_priv *iwm =
125 container_of(work, struct iwm_priv, disconnect.work);
127 if (iwm->umac_profile_active)
128 iwm_invalidate_mlme_profile(iwm);
130 clear_bit(IWM_STATUS_ASSOCIATED, &iwm->status);
131 iwm->umac_profile_active = 0;
132 memset(iwm->bssid, 0, ETH_ALEN);
137 wake_up_interruptible(&iwm->mlme_queue);
139 cfg80211_disconnected(iwm_to_ndev(iwm), 0, NULL, 0, GFP_KERNEL);
142 static void iwm_ct_kill_work(struct work_struct *work)
144 struct iwm_priv *iwm =
145 container_of(work, struct iwm_priv, ct_kill_delay.work);
146 struct wiphy *wiphy = iwm_to_wiphy(iwm);
148 IWM_INFO(iwm, "CT kill delay timeout\n");
150 wiphy_rfkill_set_hw_state(wiphy, false);
153 static int __iwm_up(struct iwm_priv *iwm);
154 static int __iwm_down(struct iwm_priv *iwm);
156 static void iwm_reset_worker(struct work_struct *work)
158 struct iwm_priv *iwm;
159 struct iwm_umac_profile *profile = NULL;
160 int uninitialized_var(ret), retry = 0;
162 iwm = container_of(work, struct iwm_priv, reset_worker);
165 * XXX: The iwm->mutex is introduced purely for this reset work,
166 * because the other users for iwm_up and iwm_down are only netdev
167 * ndo_open and ndo_stop which are already protected by rtnl.
168 * Please remove iwm->mutex together if iwm_reset_worker() is not
169 * required in the future.
171 if (!mutex_trylock(&iwm->mutex)) {
172 IWM_WARN(iwm, "We are in the middle of interface bringing "
173 "UP/DOWN. Skip driver resetting.\n");
177 if (iwm->umac_profile_active) {
178 profile = kmalloc(sizeof(struct iwm_umac_profile), GFP_KERNEL);
180 memcpy(profile, iwm->umac_profile, sizeof(*profile));
182 IWM_ERR(iwm, "Couldn't alloc memory for profile\n");
187 while (retry++ < 3) {
192 schedule_timeout_uninterruptible(10 * HZ);
196 IWM_WARN(iwm, "iwm_up() failed: %d\n", ret);
203 IWM_DBG_MLME(iwm, DBG, "Resend UMAC profile\n");
204 memcpy(iwm->umac_profile, profile, sizeof(*profile));
205 iwm_send_mlme_profile(iwm);
208 clear_bit(IWM_STATUS_RESETTING, &iwm->status);
211 mutex_unlock(&iwm->mutex);
214 static void iwm_auth_retry_worker(struct work_struct *work)
216 struct iwm_priv *iwm;
219 iwm = container_of(work, struct iwm_priv, auth_retry_worker);
220 if (iwm->umac_profile_active) {
221 ret = iwm_invalidate_mlme_profile(iwm);
226 iwm->umac_profile->sec.auth_type = UMAC_AUTH_TYPE_LEGACY_PSK;
228 ret = iwm_send_mlme_profile(iwm);
232 for (i = 0; i < IWM_NUM_KEYS; i++)
233 if (iwm->keys[i].key_len)
234 iwm_set_key(iwm, 0, &iwm->keys[i]);
236 iwm_set_tx_key(iwm, iwm->default_key);
241 static void iwm_watchdog(unsigned long data)
243 struct iwm_priv *iwm = (struct iwm_priv *)data;
245 IWM_WARN(iwm, "Watchdog expired: UMAC stalls!\n");
251 int iwm_priv_init(struct iwm_priv *iwm)
257 INIT_LIST_HEAD(&iwm->pending_notif);
258 init_waitqueue_head(&iwm->notif_queue);
259 init_waitqueue_head(&iwm->nonwifi_queue);
260 init_waitqueue_head(&iwm->wifi_ntfy_queue);
261 init_waitqueue_head(&iwm->mlme_queue);
262 memcpy(&iwm->conf, &def_iwm_conf, sizeof(struct iwm_conf));
263 spin_lock_init(&iwm->tx_credit.lock);
264 INIT_LIST_HEAD(&iwm->wifi_pending_cmd);
265 INIT_LIST_HEAD(&iwm->nonwifi_pending_cmd);
266 iwm->wifi_seq_num = UMAC_WIFI_SEQ_NUM_BASE;
267 iwm->nonwifi_seq_num = UMAC_NONWIFI_SEQ_NUM_BASE;
268 spin_lock_init(&iwm->cmd_lock);
270 INIT_DELAYED_WORK(&iwm->stats_request, iwm_statistics_request);
271 INIT_DELAYED_WORK(&iwm->disconnect, iwm_disconnect_work);
272 INIT_DELAYED_WORK(&iwm->ct_kill_delay, iwm_ct_kill_work);
273 INIT_WORK(&iwm->reset_worker, iwm_reset_worker);
274 INIT_WORK(&iwm->auth_retry_worker, iwm_auth_retry_worker);
275 INIT_LIST_HEAD(&iwm->bss_list);
277 skb_queue_head_init(&iwm->rx_list);
278 INIT_LIST_HEAD(&iwm->rx_tickets);
279 for (i = 0; i < IWM_RX_ID_HASH; i++)
280 INIT_LIST_HEAD(&iwm->rx_packets[i]);
282 INIT_WORK(&iwm->rx_worker, iwm_rx_worker);
284 iwm->rx_wq = create_singlethread_workqueue(KBUILD_MODNAME "_rx");
288 for (i = 0; i < IWM_TX_QUEUES; i++) {
289 INIT_WORK(&iwm->txq[i].worker, iwm_tx_worker);
290 snprintf(name, 32, KBUILD_MODNAME "_tx_%d", i);
292 iwm->txq[i].wq = create_singlethread_workqueue(name);
296 skb_queue_head_init(&iwm->txq[i].queue);
297 skb_queue_head_init(&iwm->txq[i].stopped_queue);
298 spin_lock_init(&iwm->txq[i].lock);
301 for (i = 0; i < IWM_NUM_KEYS; i++)
302 memset(&iwm->keys[i], 0, sizeof(struct iwm_key));
304 iwm->default_key = -1;
306 for (i = 0; i < IWM_STA_TABLE_NUM; i++)
307 for (j = 0; j < IWM_UMAC_TID_NR; j++) {
308 mutex_init(&iwm->sta_table[i].tid_info[j].mutex);
309 iwm->sta_table[i].tid_info[j].stopped = false;
312 init_timer(&iwm->watchdog);
313 iwm->watchdog.function = iwm_watchdog;
314 iwm->watchdog.data = (unsigned long)iwm;
315 mutex_init(&iwm->mutex);
317 iwm->last_fw_err = kzalloc(sizeof(struct iwm_fw_error_hdr),
319 if (iwm->last_fw_err == NULL)
325 void iwm_priv_deinit(struct iwm_priv *iwm)
329 for (i = 0; i < IWM_TX_QUEUES; i++)
330 destroy_workqueue(iwm->txq[i].wq);
332 destroy_workqueue(iwm->rx_wq);
333 kfree(iwm->last_fw_err);
337 * We reset all the structures, and we reset the UMAC.
338 * After calling this routine, you're expected to reload
341 void iwm_reset(struct iwm_priv *iwm)
343 struct iwm_notif *notif, *next;
345 if (test_bit(IWM_STATUS_READY, &iwm->status))
346 iwm_target_reset(iwm);
348 if (test_bit(IWM_STATUS_RESETTING, &iwm->status)) {
350 set_bit(IWM_STATUS_RESETTING, &iwm->status);
355 list_for_each_entry_safe(notif, next, &iwm->pending_notif, pending) {
356 list_del(¬if->pending);
363 flush_workqueue(iwm->rx_wq);
368 void iwm_resetting(struct iwm_priv *iwm)
370 set_bit(IWM_STATUS_RESETTING, &iwm->status);
372 schedule_work(&iwm->reset_worker);
378 * We're faced with the following issue: Any host command can
379 * have an answer or not, and if there's an answer to expect,
380 * it can be treated synchronously or asynchronously.
381 * To work around the synchronous answer case, we implemented
382 * our notification mechanism.
383 * When a code path needs to wait for a command response
384 * synchronously, it calls notif_handle(), which waits for the
385 * right notification to show up, and then process it. Before
386 * starting to wait, it registered as a waiter for this specific
387 * answer (by toggling a bit in on of the handler_map), so that
388 * the rx code knows that it needs to send a notification to the
389 * waiting processes. It does so by calling iwm_notif_send(),
390 * which adds the notification to the pending notifications list,
391 * and then wakes the waiting processes up.
393 int iwm_notif_send(struct iwm_priv *iwm, struct iwm_wifi_cmd *cmd,
394 u8 cmd_id, u8 source, u8 *buf, unsigned long buf_size)
396 struct iwm_notif *notif;
398 notif = kzalloc(sizeof(struct iwm_notif), GFP_KERNEL);
400 IWM_ERR(iwm, "Couldn't alloc memory for notification\n");
404 INIT_LIST_HEAD(¬if->pending);
406 notif->cmd_id = cmd_id;
408 notif->buf = kzalloc(buf_size, GFP_KERNEL);
410 IWM_ERR(iwm, "Couldn't alloc notification buffer\n");
414 notif->buf_size = buf_size;
415 memcpy(notif->buf, buf, buf_size);
416 list_add_tail(¬if->pending, &iwm->pending_notif);
418 wake_up_interruptible(&iwm->notif_queue);
423 static struct iwm_notif *iwm_notif_find(struct iwm_priv *iwm, u32 cmd,
426 struct iwm_notif *notif, *next;
428 list_for_each_entry_safe(notif, next, &iwm->pending_notif, pending) {
429 if ((notif->cmd_id == cmd) && (notif->src == source)) {
430 list_del(¬if->pending);
438 static struct iwm_notif *iwm_notif_wait(struct iwm_priv *iwm, u32 cmd,
439 u8 source, long timeout)
442 struct iwm_notif *notif;
443 unsigned long *map = NULL;
447 map = &iwm->lmac_handler_map[0];
450 map = &iwm->umac_handler_map[0];
453 map = &iwm->udma_handler_map[0];
459 ret = wait_event_interruptible_timeout(iwm->notif_queue,
460 ((notif = iwm_notif_find(iwm, cmd, source)) != NULL),
470 int iwm_notif_handle(struct iwm_priv *iwm, u32 cmd, u8 source, long timeout)
473 struct iwm_notif *notif;
475 notif = iwm_notif_wait(iwm, cmd, source, timeout);
479 ret = iwm_rx_handle_resp(iwm, notif->buf, notif->buf_size, notif->cmd);
486 static int iwm_config_boot_params(struct iwm_priv *iwm)
488 struct iwm_udma_nonwifi_cmd target_cmd;
491 /* check Wimax is off and config debug monitor */
492 if (!modparam_wimax_enable) {
494 u32 addr1 = 0x606BE258;
498 u32 addr2 = 0x606BE100;
501 u32 addr3 = 0x606BEC00;
504 target_cmd.handle_by_hw = 0;
507 target_cmd.opcode = UMAC_HDI_OUT_OPCODE_WRITE;
508 target_cmd.addr = cpu_to_le32(addr1);
509 target_cmd.op1_sz = cpu_to_le32(sizeof(u32));
512 ret = iwm_hal_send_target_cmd(iwm, &target_cmd, &data1);
514 IWM_ERR(iwm, "iwm_hal_send_target_cmd failed\n");
518 target_cmd.opcode = UMAC_HDI_OUT_OPCODE_READ_MODIFY_WRITE;
519 target_cmd.addr = cpu_to_le32(addr2);
520 target_cmd.op1_sz = cpu_to_le32(data2_set);
521 target_cmd.op2 = cpu_to_le32(data2_clr);
523 ret = iwm_hal_send_target_cmd(iwm, &target_cmd, &data1);
525 IWM_ERR(iwm, "iwm_hal_send_target_cmd failed\n");
529 target_cmd.opcode = UMAC_HDI_OUT_OPCODE_WRITE;
530 target_cmd.addr = cpu_to_le32(addr3);
531 target_cmd.op1_sz = cpu_to_le32(sizeof(u32));
534 ret = iwm_hal_send_target_cmd(iwm, &target_cmd, &data3);
536 IWM_ERR(iwm, "iwm_hal_send_target_cmd failed\n");
544 void iwm_init_default_profile(struct iwm_priv *iwm,
545 struct iwm_umac_profile *profile)
547 memset(profile, 0, sizeof(struct iwm_umac_profile));
549 profile->sec.auth_type = UMAC_AUTH_TYPE_OPEN;
550 profile->sec.flags = UMAC_SEC_FLG_LEGACY_PROFILE;
551 profile->sec.ucast_cipher = UMAC_CIPHER_TYPE_NONE;
552 profile->sec.mcast_cipher = UMAC_CIPHER_TYPE_NONE;
554 if (iwm->conf.enable_qos)
555 profile->flags |= cpu_to_le16(UMAC_PROFILE_QOS_ALLOWED);
557 profile->wireless_mode = iwm->conf.wireless_mode;
558 profile->mode = cpu_to_le32(iwm->conf.mode);
560 profile->ibss.atim = 0;
561 profile->ibss.beacon_interval = 100;
562 profile->ibss.join_only = 0;
563 profile->ibss.band = iwm->conf.ibss_band;
564 profile->ibss.channel = iwm->conf.ibss_channel;
567 void iwm_link_on(struct iwm_priv *iwm)
569 netif_carrier_on(iwm_to_ndev(iwm));
570 netif_tx_wake_all_queues(iwm_to_ndev(iwm));
572 iwm_send_umac_stats_req(iwm, 0);
575 void iwm_link_off(struct iwm_priv *iwm)
577 struct iw_statistics *wstats = &iwm->wstats;
580 netif_tx_stop_all_queues(iwm_to_ndev(iwm));
581 netif_carrier_off(iwm_to_ndev(iwm));
583 for (i = 0; i < IWM_TX_QUEUES; i++) {
584 skb_queue_purge(&iwm->txq[i].queue);
585 skb_queue_purge(&iwm->txq[i].stopped_queue);
587 iwm->txq[i].concat_count = 0;
588 iwm->txq[i].concat_ptr = iwm->txq[i].concat_buf;
590 flush_workqueue(iwm->txq[i].wq);
595 cancel_delayed_work_sync(&iwm->stats_request);
596 memset(wstats, 0, sizeof(struct iw_statistics));
597 wstats->qual.updated = IW_QUAL_ALL_INVALID;
604 iwm->resp_ie_len = 0;
606 del_timer_sync(&iwm->watchdog);
609 static void iwm_bss_list_clean(struct iwm_priv *iwm)
611 struct iwm_bss_info *bss, *next;
613 list_for_each_entry_safe(bss, next, &iwm->bss_list, node) {
614 list_del(&bss->node);
620 static int iwm_channels_init(struct iwm_priv *iwm)
624 ret = iwm_send_umac_channel_list(iwm);
626 IWM_ERR(iwm, "Send channel list failed\n");
630 ret = iwm_notif_handle(iwm, UMAC_CMD_OPCODE_GET_CHAN_INFO_LIST,
631 IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
633 IWM_ERR(iwm, "Didn't get a channel list notification\n");
640 static int __iwm_up(struct iwm_priv *iwm)
643 struct iwm_notif *notif_reboot, *notif_ack = NULL;
644 struct wiphy *wiphy = iwm_to_wiphy(iwm);
647 ret = iwm_bus_enable(iwm);
649 IWM_ERR(iwm, "Couldn't enable function\n");
653 iwm_rx_setup_handlers(iwm);
655 /* Wait for initial BARKER_REBOOT from hardware */
656 notif_reboot = iwm_notif_wait(iwm, IWM_BARKER_REBOOT_NOTIFICATION,
657 IWM_SRC_UDMA, 2 * HZ);
659 IWM_ERR(iwm, "Wait for REBOOT_BARKER timeout\n");
663 /* We send the barker back */
664 ret = iwm_bus_send_chunk(iwm, notif_reboot->buf, 16);
666 IWM_ERR(iwm, "REBOOT barker response failed\n");
671 kfree(notif_reboot->buf);
674 /* Wait for ACK_BARKER from hardware */
675 notif_ack = iwm_notif_wait(iwm, IWM_ACK_BARKER_NOTIFICATION,
676 IWM_SRC_UDMA, 2 * HZ);
678 IWM_ERR(iwm, "Wait for ACK_BARKER timeout\n");
682 kfree(notif_ack->buf);
685 /* We start to config static boot parameters */
686 ret = iwm_config_boot_params(iwm);
688 IWM_ERR(iwm, "Config boot parameters failed\n");
692 ret = iwm_read_mac(iwm, iwm_to_ndev(iwm)->dev_addr);
694 IWM_ERR(iwm, "MAC reading failed\n");
697 memcpy(iwm_to_ndev(iwm)->perm_addr, iwm_to_ndev(iwm)->dev_addr,
700 /* We can load the FWs */
701 ret = iwm_load_fw(iwm);
703 IWM_ERR(iwm, "FW loading failed\n");
707 ret = iwm_eeprom_fat_channels(iwm);
709 IWM_ERR(iwm, "Couldnt read HT channels EEPROM entries\n");
714 * Read our SKU capabilities.
715 * If it's valid, we AND the configured wireless mode with the
716 * device EEPROM value as the current profile wireless mode.
718 wireless_mode = iwm_eeprom_wireless_mode(iwm);
720 iwm->conf.wireless_mode &= wireless_mode;
721 if (iwm->umac_profile)
722 iwm->umac_profile->wireless_mode =
723 iwm->conf.wireless_mode;
725 IWM_ERR(iwm, "Wrong SKU capabilities: 0x%x\n",
726 *((u16 *)iwm_eeprom_access(iwm, IWM_EEPROM_SKU_CAP)));
728 snprintf(wiphy->fw_version, sizeof(wiphy->fw_version), "L%s_U%s",
729 iwm->lmac_version, iwm->umac_version);
731 /* We configure the UMAC and enable the wifi module */
732 ret = iwm_send_umac_config(iwm,
733 cpu_to_le32(UMAC_RST_CTRL_FLG_WIFI_CORE_EN) |
734 cpu_to_le32(UMAC_RST_CTRL_FLG_WIFI_LINK_EN) |
735 cpu_to_le32(UMAC_RST_CTRL_FLG_WIFI_MLME_EN));
737 IWM_ERR(iwm, "UMAC config failed\n");
741 ret = iwm_notif_handle(iwm, UMAC_NOTIFY_OPCODE_WIFI_CORE_STATUS,
742 IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
744 IWM_ERR(iwm, "Didn't get a wifi core status notification\n");
748 if (iwm->core_enabled != (UMAC_NTFY_WIFI_CORE_STATUS_LINK_EN |
749 UMAC_NTFY_WIFI_CORE_STATUS_MLME_EN)) {
750 IWM_DBG_BOOT(iwm, DBG, "Not all cores enabled:0x%x\n",
752 ret = iwm_notif_handle(iwm, UMAC_NOTIFY_OPCODE_WIFI_CORE_STATUS,
753 IWM_SRC_UMAC, WAIT_NOTIF_TIMEOUT);
755 IWM_ERR(iwm, "Didn't get a core status notification\n");
759 if (iwm->core_enabled != (UMAC_NTFY_WIFI_CORE_STATUS_LINK_EN |
760 UMAC_NTFY_WIFI_CORE_STATUS_MLME_EN)) {
761 IWM_ERR(iwm, "Not all cores enabled: 0x%x\n",
765 IWM_INFO(iwm, "All cores enabled\n");
769 ret = iwm_channels_init(iwm);
771 IWM_ERR(iwm, "Couldn't init channels\n");
775 /* Set the READY bit to indicate interface is brought up successfully */
776 set_bit(IWM_STATUS_READY, &iwm->status);
781 iwm_eeprom_exit(iwm);
784 ret = iwm_bus_disable(iwm);
786 IWM_ERR(iwm, "Couldn't disable function\n");
791 int iwm_up(struct iwm_priv *iwm)
795 mutex_lock(&iwm->mutex);
797 mutex_unlock(&iwm->mutex);
802 static int __iwm_down(struct iwm_priv *iwm)
806 /* The interface is already down */
807 if (!test_bit(IWM_STATUS_READY, &iwm->status))
810 if (iwm->scan_request) {
811 cfg80211_scan_done(iwm->scan_request, true);
812 iwm->scan_request = NULL;
815 clear_bit(IWM_STATUS_READY, &iwm->status);
817 iwm_eeprom_exit(iwm);
818 iwm_bss_list_clean(iwm);
819 iwm_init_default_profile(iwm, iwm->umac_profile);
820 iwm->umac_profile_active = false;
821 iwm->default_key = -1;
822 iwm->core_enabled = 0;
824 ret = iwm_bus_disable(iwm);
826 IWM_ERR(iwm, "Couldn't disable function\n");
833 int iwm_down(struct iwm_priv *iwm)
837 mutex_lock(&iwm->mutex);
838 ret = __iwm_down(iwm);
839 mutex_unlock(&iwm->mutex);