staging: vt6656: Remove rx handing from RXvWorkItem
authorMalcolm Priestley <tvboxspy@gmail.com>
Sat, 28 Jun 2014 22:55:42 +0000 (23:55 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 29 Jun 2014 21:25:53 +0000 (14:25 -0700)
In s_nsBulkInUsbIoCompleteRead reuse or reallocate sb_buff and resubmit
urb.

In device_alloc_bufs allocate memory to rcb individually and
call PIPEnsBulkInUsbRead to submit the urbs

Change handling to free rcb in device_free_rx_bufs

Remove calls to workqueue.

Signed-off-by: Malcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/vt6656/main_usb.c
drivers/staging/vt6656/usbpipe.c

index 86d9470..19d42ce 100644 (file)
@@ -514,6 +514,8 @@ static void device_free_rx_bufs(struct vnt_private *priv)
 
        for (ii = 0; ii < priv->cbRD; ii++) {
                rcb = priv->apRCB[ii];
+               if (!rcb)
+                       continue;
 
                /* deallocate URBs */
                if (rcb->pUrb) {
@@ -524,9 +526,9 @@ static void device_free_rx_bufs(struct vnt_private *priv)
                /* deallocate skb */
                if (rcb->skb)
                        dev_kfree_skb(rcb->skb);
-       }
 
-       kfree(priv->pRCBMem);
+               kfree(rcb);
+       }
 
        return;
 }
@@ -576,22 +578,16 @@ static bool device_alloc_bufs(struct vnt_private *priv)
                tx_context->in_use = false;
        }
 
-       /* allocate RCB mem */
-       priv->pRCBMem = kzalloc((sizeof(struct vnt_rcb) * priv->cbRD),
-                                                               GFP_KERNEL);
-       if (priv->pRCBMem == NULL) {
-               dev_err(&priv->usb->dev, "alloc rx usb context failed\n");
-               goto free_tx;
-       }
-
-       priv->FirstRecvFreeList = NULL;
-       priv->LastRecvFreeList = NULL;
-       priv->NumRecvFreeList = 0;
+       for (ii = 0; ii < priv->cbRD; ii++) {
+               priv->apRCB[ii] = kzalloc(sizeof(struct vnt_rcb), GFP_KERNEL);
+               if (!priv->apRCB[ii]) {
+                       dev_err(&priv->usb->dev,
+                                       "failed to allocate rcb no %d\n", ii);
+                       goto free_rx_tx;
+               }
 
-       rcb = (struct vnt_rcb *)priv->pRCBMem;
+               rcb = priv->apRCB[ii];
 
-       for (ii = 0; ii < priv->cbRD; ii++) {
-               priv->apRCB[ii] = rcb;
                rcb->pDevice = priv;
 
                /* allocate URBs */
@@ -611,11 +607,9 @@ static bool device_alloc_bufs(struct vnt_private *priv)
 
                rcb->bBoolInUse = false;
 
-               EnqueueRCB(priv->FirstRecvFreeList,
-                                               priv->LastRecvFreeList, rcb);
-
-               priv->NumRecvFreeList++;
-               rcb++;
+               /* submit rx urb */
+               if (PIPEnsBulkInUsbRead(priv, rcb))
+                       goto free_rx_tx;
        }
 
        priv->pInterruptURB = usb_alloc_urb(0, GFP_ATOMIC);
@@ -678,7 +672,6 @@ static int vnt_start(struct ieee80211_hw *hw)
 
        priv->int_interval = 1;  /* bInterval is set to 1 */
 
-       schedule_work(&priv->read_work_item);
        INTvWorkItem(priv);
 
        priv->flags |= DEVICE_FLAGS_OPENED;
@@ -722,7 +715,6 @@ static void vnt_stop(struct ieee80211_hw *hw)
        MP_CLEAR_FLAG(priv, fMP_POST_READS);
 
        cancel_delayed_work_sync(&priv->run_command_work);
-       cancel_work_sync(&priv->read_work_item);
 
        priv->bCmdRunning = false;
 
index 6a7e692..428193e 100644 (file)
@@ -230,9 +230,6 @@ int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb)
        int status = 0;
        struct urb *urb;
 
-       if (priv->Flags & fMP_DISCONNECTED)
-               return STATUS_FAILURE;
-
        urb = rcb->pUrb;
        if (rcb->skb == NULL) {
                dev_dbg(&priv->usb->dev, "rcb->skb is null\n");
@@ -303,16 +300,24 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
                spin_unlock_irqrestore(&priv->lock, flags);
        }
 
-       rcb->Ref--;
-       if (rcb->Ref == 0) {
-               dev_dbg(&priv->usb->dev,
-                               "RxvFreeNormal %d\n", priv->NumRecvFreeList);
+       if (re_alloc_skb) {
+               rcb->skb = dev_alloc_skb(priv->rx_buf_sz);
+               if (!rcb->skb) {
+                       dev_dbg(&priv->usb->dev, "Failed to re-alloc rx skb\n");
 
-               spin_lock_irqsave(&priv->lock, flags);
+                       rcb->bBoolInUse = false;
 
-               RXvFreeRCB(rcb, re_alloc_skb);
+                       return;
+               }
 
-               spin_unlock_irqrestore(&priv->lock, flags);
+               urb->transfer_buffer = skb_put(rcb->skb,
+                                               skb_tailroom(rcb->skb));
+       }
+
+       if (usb_submit_urb(urb, GFP_ATOMIC)) {
+               dev_dbg(&priv->usb->dev, "Failed to re submit rx skb\n");
+
+               rcb->bBoolInUse = false;
        }
 
        return;