Merge branch 'upstream-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jgarzi...
[pandora-kernel.git] / drivers / net / wireless / ath / ath9k / hif_usb.c
index 74872ca..77b3591 100644 (file)
@@ -107,12 +107,14 @@ static inline void ath9k_skb_queue_purge(struct hif_device_usb *hif_dev,
 static void hif_usb_tx_cb(struct urb *urb)
 {
        struct tx_buf *tx_buf = (struct tx_buf *) urb->context;
-       struct hif_device_usb *hif_dev = tx_buf->hif_dev;
+       struct hif_device_usb *hif_dev;
        struct sk_buff *skb;
 
-       if (!hif_dev || !tx_buf)
+       if (!tx_buf || !tx_buf->hif_dev)
                return;
 
+       hif_dev = tx_buf->hif_dev;
+
        switch (urb->status) {
        case 0:
                break;
@@ -607,6 +609,10 @@ static int ath9k_hif_usb_alloc_tx_urbs(struct hif_device_usb *hif_dev)
 
        return 0;
 err:
+       if (tx_buf) {
+               kfree(tx_buf->buf);
+               kfree(tx_buf);
+       }
        ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
        return -ENOMEM;
 }
@@ -735,6 +741,14 @@ err:
        return -ENOMEM;
 }
 
+static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
+{
+       usb_kill_anchored_urbs(&hif_dev->regout_submitted);
+       ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
+       ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
+       ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
+}
+
 static int ath9k_hif_usb_download_fw(struct hif_device_usb *hif_dev)
 {
        int transfer, err;
@@ -794,14 +808,6 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev,
                goto err_fw_req;
        }
 
-       /* Download firmware */
-       ret = ath9k_hif_usb_download_fw(hif_dev);
-       if (ret) {
-               dev_err(&hif_dev->udev->dev,
-                       "ath9k_htc: Firmware - %s download failed\n", fw_name);
-               goto err_fw_download;
-       }
-
        /* Alloc URBs */
        ret = ath9k_hif_usb_alloc_urbs(hif_dev);
        if (ret) {
@@ -810,25 +816,25 @@ static int ath9k_hif_usb_dev_init(struct hif_device_usb *hif_dev,
                goto err_urb;
        }
 
+       /* Download firmware */
+       ret = ath9k_hif_usb_download_fw(hif_dev);
+       if (ret) {
+               dev_err(&hif_dev->udev->dev,
+                       "ath9k_htc: Firmware - %s download failed\n", fw_name);
+               goto err_fw_download;
+       }
+
        return 0;
 
-err_urb:
-       /* Nothing */
 err_fw_download:
+       ath9k_hif_usb_dealloc_urbs(hif_dev);
+err_urb:
        release_firmware(hif_dev->firmware);
 err_fw_req:
        hif_dev->firmware = NULL;
        return ret;
 }
 
-static void ath9k_hif_usb_dealloc_urbs(struct hif_device_usb *hif_dev)
-{
-       usb_kill_anchored_urbs(&hif_dev->regout_submitted);
-       ath9k_hif_usb_dealloc_reg_in_urb(hif_dev);
-       ath9k_hif_usb_dealloc_tx_urbs(hif_dev);
-       ath9k_hif_usb_dealloc_rx_urbs(hif_dev);
-}
-
 static void ath9k_hif_usb_dev_deinit(struct hif_device_usb *hif_dev)
 {
        ath9k_hif_usb_dealloc_urbs(hif_dev);
@@ -859,21 +865,21 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
 #endif
        usb_set_intfdata(interface, hif_dev);
 
+       hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev, &hif_usb,
+                                                &hif_dev->udev->dev);
+       if (hif_dev->htc_handle == NULL) {
+               ret = -ENOMEM;
+               goto err_htc_hw_alloc;
+       }
+
        ret = ath9k_hif_usb_dev_init(hif_dev, fw_name);
        if (ret) {
                ret = -EINVAL;
                goto err_hif_init_usb;
        }
 
-       hif_dev->htc_handle = ath9k_htc_hw_alloc(hif_dev);
-       if (hif_dev->htc_handle == NULL) {
-               ret = -ENOMEM;
-               goto err_htc_hw_alloc;
-       }
-
-       ret = ath9k_htc_hw_init(&hif_usb, hif_dev->htc_handle, hif_dev,
-                               &hif_dev->udev->dev, hif_dev->device_id,
-                               ATH9K_HIF_USB);
+       ret = ath9k_htc_hw_init(hif_dev->htc_handle,
+                               &hif_dev->udev->dev, hif_dev->device_id);
        if (ret) {
                ret = -EINVAL;
                goto err_htc_hw_init;
@@ -884,10 +890,10 @@ static int ath9k_hif_usb_probe(struct usb_interface *interface,
        return 0;
 
 err_htc_hw_init:
-       ath9k_htc_hw_free(hif_dev->htc_handle);
-err_htc_hw_alloc:
        ath9k_hif_usb_dev_deinit(hif_dev);
 err_hif_init_usb:
+       ath9k_htc_hw_free(hif_dev->htc_handle);
+err_htc_hw_alloc:
        usb_set_intfdata(interface, NULL);
        kfree(hif_dev);
        usb_put_dev(udev);