rtl8xxxu: Reset device on module unload if still attached
authorJes Sorensen <Jes.Sorensen@redhat.com>
Fri, 9 Sep 2016 18:01:24 +0000 (14:01 -0400)
committerKalle Valo <kvalo@codeaurora.org>
Wed, 14 Sep 2016 17:01:08 +0000 (20:01 +0300)
If the USB dongle is still attached, reset it on module unload to
avoid scans failing when reloading the driver.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c

index c362083..d2611a4 100644 (file)
@@ -6129,6 +6129,11 @@ static void rtl8xxxu_disconnect(struct usb_interface *interface)
        mutex_destroy(&priv->usb_buf_mutex);
        mutex_destroy(&priv->h2c_mutex);
 
+       if (priv->udev->state != USB_STATE_NOTATTACHED) {
+               dev_info(&priv->udev->dev,
+                        "Device still attached, trying to reset\n");
+               usb_reset_device(priv->udev);
+       }
        usb_put_dev(priv->udev);
        ieee80211_free_hw(hw);
 }