@@ -408,10 +408,6 @@ int mt76x0_init_hardware(struct mt76x0_dev *dev)
if (ret)
return ret;
- ret = mt76u_alloc_queues(&dev->mt76);
- if (ret < 0)
- return ret;
-
mt76x0_init_mac_registers(dev);
if (!mt76_poll_msec(dev, MT_MAC_STATUS,
@@ -614,6 +610,14 @@ int mt76x0_register_device(struct mt76x0_dev *dev)
struct wiphy *wiphy = hw->wiphy;
int ret;
+ ret = mt76u_mcu_init_rx(mdev);
+ if (ret < 0)
+ return ret;
+
+ ret = mt76u_alloc_queues(mdev);
+ if (ret < 0)
+ return ret;
+
ret = mt76x0_init_hardware(dev);
if (ret)
return ret;
@@ -387,11 +387,5 @@ int mt76x0_mcu_init(struct mt76x0_dev *dev)
int mt76x0_mcu_cmd_init(struct mt76x0_dev *dev)
{
- int ret;
-
- ret = mt76u_mcu_init_rx(&dev->mt76);
- if (ret)
- return ret;
-
return mt76x0_mcu_function_select(dev, Q_SELECT, 1);
}
@@ -124,29 +124,49 @@ static void mt76x0_disconnect(struct usb_interface *usb_intf)
ieee80211_free_hw(dev->mt76.hw);
}
-static int mt76x0_suspend(struct usb_interface *usb_intf, pm_message_t state)
+static int __maybe_unused mt76x0_suspend(struct usb_interface *usb_intf,
+ pm_message_t state)
{
struct mt76x0_dev *dev = usb_get_intfdata(usb_intf);
+ struct mt76_usb *usb = &dev->mt76.usb;
- mt76x0_cleanup(dev);
+ mt76u_stop_queues(&dev->mt76);
+ mt76x0_mac_stop(dev);
+ usb_kill_urb(usb->mcu.res.urb);
return 0;
}
-static int mt76x0_resume(struct usb_interface *usb_intf)
+static int __maybe_unused mt76x0_resume(struct usb_interface *usb_intf)
{
struct mt76x0_dev *dev = usb_get_intfdata(usb_intf);
+ struct mt76_usb *usb = &dev->mt76.usb;
int ret;
- ret = mt76x0_init_hardware(dev);
- if (ret) {
- mt76x0_cleanup(dev);
- return ret;
- }
+ reinit_completion(&usb->mcu.cmpl);
+ ret = mt76u_submit_buf(&dev->mt76, USB_DIR_IN,
+ MT_EP_IN_CMD_RESP,
+ &usb->mcu.res, GFP_KERNEL,
+ mt76u_mcu_complete_urb,
+ &usb->mcu.cmpl);
+ if (ret < 0)
+ goto err;
- set_bit(MT76_STATE_INITIALIZED, &dev->mt76.state);
+ ret = mt76u_submit_rx_buffers(&dev->mt76);
+ if (ret < 0)
+ goto err;
+
+ tasklet_enable(&usb->rx_tasklet);
+ tasklet_enable(&usb->tx_tasklet);
+
+ ret = mt76x0_init_hardware(dev);
+ if (ret)
+ goto err;
return 0;
+err:
+ mt76x0_cleanup(dev);
+ return ret;
}
MODULE_DEVICE_TABLE(usb, mt76x0_device_table);