for (ii = 0; ii < priv->cbRD; ii++) {
rcb = priv->apRCB[ii];
+ if (!rcb)
+ continue;
/* deallocate URBs */
if (rcb->pUrb) {
/* deallocate skb */
if (rcb->skb)
dev_kfree_skb(rcb->skb);
- }
- kfree(priv->pRCBMem);
+ kfree(rcb);
+ }
return;
}
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 */
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);
priv->int_interval = 1; /* bInterval is set to 1 */
- schedule_work(&priv->read_work_item);
INTvWorkItem(priv);
priv->flags |= DEVICE_FLAGS_OPENED;
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;
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");
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;