dwork_hw_scan.work);
int ret;
+ if (priv->device_unplugged)
+ return;
+
mutex_lock(&priv->mtx);
ret = at76_get_cmd_status(priv->udev, CMD_SCAN);
at76_dbg(DBG_MAC80211, "%s():", __func__);
+ if (priv->device_unplugged)
+ return 0;
+
mutex_lock(&priv->mtx);
ieee80211_stop_queues(hw);
flags = changed_flags & AT76_SUPPORTED_FILTERS;
*total_flags = AT76_SUPPORTED_FILTERS;
+ /* Bail out after updating flags to prevent a WARN_ON in mac80211. */
+ if (priv->device_unplugged)
+ return;
+
/* FIXME: access to priv->promisc should be protected with
* priv->mtx, but it's impossible because this function needs to be
* atomic */
INIT_WORK(&priv->work_submit_rx, at76_work_submit_rx);
INIT_DELAYED_WORK(&priv->dwork_hw_scan, at76_dwork_hw_scan);
- priv->rx_tasklet.func = at76_rx_tasklet;
- priv->rx_tasklet.data = 0;
+ tasklet_init(&priv->rx_tasklet, at76_rx_tasklet, 0);
priv->pm_mode = AT76_PM_OFF;
priv->pm_period = 0;
priv->scan_min_time = DEF_SCAN_MIN_TIME;
priv->scan_max_time = DEF_SCAN_MAX_TIME;
priv->scan_mode = SCAN_TYPE_ACTIVE;
+ priv->device_unplugged = 0;
/* mac80211 initialisation */
priv->hw->wiphy->max_scan_ssids = 1;
/* The device is gone, don't bother turning it off */
priv->device_unplugged = 1;
- if (priv->mac80211_registered)
- ieee80211_unregister_hw(priv->hw);
+ tasklet_kill(&priv->rx_tasklet);
- /* assuming we used keventd, it must quiesce too */
- flush_scheduled_work();
-
- kfree(priv->bulk_out_buffer);
+ if (priv->mac80211_registered) {
+ flush_workqueue(priv->hw->workqueue);
+ ieee80211_unregister_hw(priv->hw);
+ }
if (priv->tx_urb) {
usb_kill_urb(priv->tx_urb);
at76_dbg(DBG_PROC_ENTRY, "%s: unlinked urbs", __func__);
+ kfree(priv->bulk_out_buffer);
+
if (priv->rx_skb)
kfree_skb(priv->rx_skb);