USB: rename usb_buffer_alloc() and usb_buffer_free() users
[linux-2.6.git] / drivers / net / wireless / ath / ar9170 / usb.c
index 99a6da4..a1f5444 100644 (file)
@@ -202,7 +202,7 @@ resubmit:
        return;
 
 free:
-       usb_buffer_free(aru->udev, 64, urb->transfer_buffer, urb->transfer_dma);
+       usb_free_coherent(aru->udev, 64, urb->transfer_buffer, urb->transfer_dma);
 }
 
 static void ar9170_usb_rx_completed(struct urb *urb)
@@ -283,7 +283,7 @@ static int ar9170_usb_alloc_rx_irq_urb(struct ar9170_usb *aru)
        if (!urb)
                goto out;
 
-       ibuf = usb_buffer_alloc(aru->udev, 64, GFP_KERNEL, &urb->transfer_dma);
+       ibuf = usb_alloc_coherent(aru->udev, 64, GFP_KERNEL, &urb->transfer_dma);
        if (!ibuf)
                goto out;
 
@@ -296,8 +296,8 @@ static int ar9170_usb_alloc_rx_irq_urb(struct ar9170_usb *aru)
        err = usb_submit_urb(urb, GFP_KERNEL);
        if (err) {
                usb_unanchor_urb(urb);
-               usb_buffer_free(aru->udev, 64, urb->transfer_buffer,
-                               urb->transfer_dma);
+               usb_free_coherent(aru->udev, 64, urb->transfer_buffer,
+                                 urb->transfer_dma);
        }
 
 out:
@@ -727,12 +727,16 @@ static void ar9170_usb_firmware_failed(struct ar9170_usb *aru)
 {
        struct device *parent = aru->udev->dev.parent;
 
+       complete(&aru->firmware_loading_complete);
+
        /* unbind anything failed */
        if (parent)
                down(&parent->sem);
        device_release_driver(&aru->udev->dev);
        if (parent)
                up(&parent->sem);
+
+       usb_put_dev(aru->udev);
 }
 
 static void ar9170_usb_firmware_finish(const struct firmware *fw, void *context)
@@ -761,6 +765,8 @@ static void ar9170_usb_firmware_finish(const struct firmware *fw, void *context)
        if (err)
                goto err_unrx;
 
+       complete(&aru->firmware_loading_complete);
+       usb_put_dev(aru->udev);
        return;
 
  err_unrx:
@@ -858,6 +864,7 @@ static int ar9170_usb_probe(struct usb_interface *intf,
        init_usb_anchor(&aru->tx_pending);
        init_usb_anchor(&aru->tx_submitted);
        init_completion(&aru->cmd_wait);
+       init_completion(&aru->firmware_loading_complete);
        spin_lock_init(&aru->tx_urb_lock);
 
        aru->tx_pending_urbs = 0;
@@ -877,6 +884,7 @@ static int ar9170_usb_probe(struct usb_interface *intf,
        if (err)
                goto err_freehw;
 
+       usb_get_dev(aru->udev);
        return request_firmware_nowait(THIS_MODULE, 1, "ar9170.fw",
                                       &aru->udev->dev, GFP_KERNEL, aru,
                                       ar9170_usb_firmware_step2);
@@ -896,6 +904,9 @@ static void ar9170_usb_disconnect(struct usb_interface *intf)
                return;
 
        aru->common.state = AR9170_IDLE;
+
+       wait_for_completion(&aru->firmware_loading_complete);
+
        ar9170_unregister(&aru->common);
        ar9170_usb_cancel_urbs(aru);