Commit 35491de7 authored by Malcolm Priestley's avatar Malcolm Priestley Committed by Greg Kroah-Hartman

staging: vt6656: Clean up device_alloc_bufs

Clean up white space, comments and camel case.

pDevice -> priv
pTxContext -> tx_context
pRCB -> rcb
Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 29263661
...@@ -804,88 +804,102 @@ static void device_free_int_bufs(struct vnt_private *pDevice) ...@@ -804,88 +804,102 @@ static void device_free_int_bufs(struct vnt_private *pDevice)
return; return;
} }
static bool device_alloc_bufs(struct vnt_private *pDevice) static bool device_alloc_bufs(struct vnt_private *priv)
{ {
struct vnt_usb_send_context *pTxContext; struct vnt_usb_send_context *tx_context;
struct vnt_rcb *pRCB; struct vnt_rcb *rcb;
int ii; int ii;
for (ii = 0; ii < pDevice->cbTD; ii++) { for (ii = 0; ii < priv->cbTD; ii++) {
tx_context = kmalloc(sizeof(struct vnt_usb_send_context),
GFP_KERNEL);
if (tx_context == NULL) {
DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
"%s : allocate tx usb context failed\n",
priv->dev->name);
goto free_tx;
}
pTxContext = kmalloc(sizeof(struct vnt_usb_send_context), GFP_KERNEL); priv->apTD[ii] = tx_context;
if (pTxContext == NULL) { tx_context->pDevice = priv;
DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : allocate tx usb context failed\n", pDevice->dev->name);
goto free_tx; /* allocate URBs */
} tx_context->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
pDevice->apTD[ii] = pTxContext; if (tx_context->pUrb == NULL) {
pTxContext->pDevice = (void *) pDevice; DBG_PRT(MSG_LEVEL_ERR,
/* allocate URBs */ KERN_ERR "alloc tx urb failed\n");
pTxContext->pUrb = usb_alloc_urb(0, GFP_ATOMIC); goto free_tx;
if (pTxContext->pUrb == NULL) { }
DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "alloc tx urb failed\n");
goto free_tx;
}
pTxContext->bBoolInUse = false;
}
/* allocate RCB mem */ tx_context->bBoolInUse = false;
pDevice->pRCBMem = kzalloc((sizeof(struct vnt_rcb) * pDevice->cbRD), }
/* allocate RCB mem */
priv->pRCBMem = kzalloc((sizeof(struct vnt_rcb) * priv->cbRD),
GFP_KERNEL); GFP_KERNEL);
if (pDevice->pRCBMem == NULL) { if (priv->pRCBMem == NULL) {
DBG_PRT(MSG_LEVEL_ERR,KERN_ERR "%s : alloc rx usb context failed\n", pDevice->dev->name); DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
goto free_tx; "%s : alloc rx usb context failed\n",
} priv->dev->name);
goto free_tx;
}
pDevice->FirstRecvFreeList = NULL; priv->FirstRecvFreeList = NULL;
pDevice->LastRecvFreeList = NULL; priv->LastRecvFreeList = NULL;
pDevice->FirstRecvMngList = NULL; priv->FirstRecvMngList = NULL;
pDevice->LastRecvMngList = NULL; priv->LastRecvMngList = NULL;
pDevice->NumRecvFreeList = 0; priv->NumRecvFreeList = 0;
pRCB = (struct vnt_rcb *)pDevice->pRCBMem; rcb = (struct vnt_rcb *)priv->pRCBMem;
for (ii = 0; ii < pDevice->cbRD; ii++) { for (ii = 0; ii < priv->cbRD; ii++) {
priv->apRCB[ii] = rcb;
rcb->pDevice = priv;
pDevice->apRCB[ii] = pRCB; /* allocate URBs */
pRCB->pDevice = (void *) pDevice; rcb->pUrb = usb_alloc_urb(0, GFP_ATOMIC);
/* allocate URBs */ if (rcb->pUrb == NULL) {
pRCB->pUrb = usb_alloc_urb(0, GFP_ATOMIC); DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
" Failed to alloc rx urb\n");
goto free_rx_tx;
}
if (pRCB->pUrb == NULL) { rcb->skb = netdev_alloc_skb(priv->dev, priv->rx_buf_sz);
DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx urb\n"); if (rcb->skb == NULL) {
goto free_rx_tx; DBG_PRT(MSG_LEVEL_ERR, KERN_ERR
} " Failed to alloc rx skb\n");
pRCB->skb = netdev_alloc_skb(pDevice->dev, pDevice->rx_buf_sz); goto free_rx_tx;
if (pRCB->skb == NULL) { }
DBG_PRT(MSG_LEVEL_ERR,KERN_ERR" Failed to alloc rx skb\n");
goto free_rx_tx; rcb->bBoolInUse = false;
}
pRCB->bBoolInUse = false;
EnqueueRCB(pDevice->FirstRecvFreeList, pDevice->LastRecvFreeList, pRCB);
pDevice->NumRecvFreeList++;
pRCB++;
}
pDevice->pInterruptURB = usb_alloc_urb(0, GFP_ATOMIC); EnqueueRCB(priv->FirstRecvFreeList,
if (pDevice->pInterruptURB == NULL) { priv->LastRecvFreeList, rcb);
DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int urb\n");
goto free_rx_tx; priv->NumRecvFreeList++;
rcb++;
} }
pDevice->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL); priv->pInterruptURB = usb_alloc_urb(0, GFP_ATOMIC);
if (pDevice->int_buf.data_buf == NULL) { if (priv->pInterruptURB == NULL) {
DBG_PRT(MSG_LEVEL_ERR,KERN_ERR"Failed to alloc int buf\n"); DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc int urb\n");
usb_free_urb(pDevice->pInterruptURB); goto free_rx_tx;
goto free_rx_tx;
} }
return true; priv->int_buf.data_buf = kmalloc(MAX_INTERRUPT_SIZE, GFP_KERNEL);
if (priv->int_buf.data_buf == NULL) {
DBG_PRT(MSG_LEVEL_ERR, KERN_ERR"Failed to alloc int buf\n");
usb_free_urb(priv->pInterruptURB);
goto free_rx_tx;
}
return true;
free_rx_tx: free_rx_tx:
device_free_rx_bufs(pDevice); device_free_rx_bufs(priv);
free_tx: free_tx:
device_free_tx_bufs(pDevice); device_free_tx_bufs(priv);
return false; return false;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment