mt7601u: don't cleanup device second time after .resume()
authorJakub Kicinski <kubakici@wp.pl>
Tue, 2 Jun 2015 19:11:27 +0000 (21:11 +0200)
committerKalle Valo <kvalo@codeaurora.org>
Mon, 8 Jun 2015 11:28:07 +0000 (14:28 +0300)
Make sure .disconnect() doesn't cleanup the device if
.resume() failed.  This may happen when device is removed
during suspend.

Signed-off-by: Jakub Kicinski <kubakici@wp.pl>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/mediatek/mt7601u/init.c
drivers/net/wireless/mediatek/mt7601u/usb.c

index 1fc86e865c8caaced6c294ea4b1620253f91f6f6..45eb0796a2e5456a9b4ffc749490ecd7d6b7fac0 100644 (file)
@@ -427,6 +427,9 @@ err:
 
 void mt7601u_cleanup(struct mt7601u_dev *dev)
 {
+       if (!test_and_clear_bit(MT7601U_STATE_INITIALIZED, &dev->state))
+               return;
+
        mt7601u_stop_hardware(dev);
        mt7601u_dma_cleanup(dev);
        mt7601u_mcu_cmd_deinit(dev);
index 99e2b3997bfa0dc7dcf8fcbeb67ddb1a83b446b3..54dba400186511bf2842972f631bd2dde51c5a46 100644 (file)
@@ -338,8 +338,15 @@ static int mt7601u_suspend(struct usb_interface *usb_intf, pm_message_t state)
 static int mt7601u_resume(struct usb_interface *usb_intf)
 {
        struct mt7601u_dev *dev = usb_get_intfdata(usb_intf);
+       int ret;
+
+       ret = mt7601u_init_hardware(dev);
+       if (ret)
+               return ret;
+
+       set_bit(MT7601U_STATE_INITIALIZED, &dev->state);
 
-       return mt7601u_init_hardware(dev);
+       return 0;
 }
 
 MODULE_DEVICE_TABLE(usb, mt7601u_device_table);