Get rid of unnessary else statement by !(MP_IS_READY(pDevice) &&
pDevice->Flags & fMP_POST_WRITES)
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 10 ++++------
1 file changed, 4 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 1fc382d..a93d0ff 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -548,7 +548,10 @@ int PIPEnsSendBulkOut(struct vnt_private *pDevice,
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n");
- if (MP_IS_READY(pDevice) && (pDevice->Flags & fMP_POST_WRITES)) {
+ if (!(MP_IS_READY(pDevice) && pDevice->Flags & fMP_POST_WRITES)) {
+ pContext->bBoolInUse = false;
+ return STATUS_RESOURCES;
+ }
pUrb = pContext->pUrb;
pDevice->ulBulkOutPosted++;
@@ -570,11 +573,6 @@ int PIPEnsSendBulkOut(struct vnt_private *pDevice,
return STATUS_FAILURE;
}
return STATUS_PENDING;
- }
- else {
- pContext->bBoolInUse = false;
- return STATUS_RESOURCES;
- }
}
/*
--
1.9.0
Use switch on urb->status
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 87601b7..1cab7a3 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -473,21 +473,22 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n");
- if (urb->status) {
- pDevice->ulBulkInError++;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK In failed %d\n", urb->status);
-//todo...xxxxxx
-// if (status == USBD_STATUS_CRC) {
-// pDevice->ulBulkInContCRCError++;
-// }
-// if (status == STATUS_DEVICE_NOT_CONNECTED )
-// {
-// MP_SET_FLAG(pDevice, fMP_DISCONNECTED);
-// }
- } else {
- pDevice->ulBulkInContCRCError = 0;
- pDevice->ulBulkInBytesRead += urb->actual_length;
- }
+ switch (urb->status) {
+ case 0:
+ pDevice->ulBulkInContCRCError = 0;
+ pDevice->ulBulkInBytesRead += urb->actual_length;
+ break;
+ case -ECONNRESET:
+ case -ENOENT:
+ case -ESHUTDOWN:
+ return;
+ case -ETIMEDOUT:
+ default:
+ pDevice->ulBulkInError++;
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+ "BULK In failed %d\n", urb->status);
+ break;
+ }
if (urb->actual_length) {
spin_lock(&pDevice->lock);
--
1.9.0
Remove unnecessary cast to void * urb->context
Reported-by: Joe Perches <[email protected]>
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 1477def..54c68a5 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -347,7 +347,7 @@ int PIPEnsInterruptRead(struct vnt_private *priv)
static void s_nsInterruptUsbIoCompleteRead(struct urb *urb)
{
- struct vnt_private *priv = (struct vnt_private *)urb->context;
+ struct vnt_private *priv = urb->context;
int status;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
@@ -465,7 +465,7 @@ int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb)
static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
{
- struct vnt_rcb *rcb = (struct vnt_rcb *)urb->context;
+ struct vnt_rcb *rcb = urb->context;
struct vnt_private *priv = rcb->pDevice;
int re_alloc_skb = false;
@@ -592,8 +592,7 @@ int PIPEnsSendBulkOut(struct vnt_private *priv,
static void s_nsBulkOutIoCompleteWrite(struct urb *urb)
{
- struct vnt_usb_send_context *context =
- (struct vnt_usb_send_context *)urb->context;
+ struct vnt_usb_send_context *context = urb->context;
struct vnt_private *priv = context->pDevice;
u8 context_type = context->type;
unsigned long buf_len = context->uBufLen;
--
1.9.0
Reorder in size and remove dead member Next.
Reported-by: Joe Perches <[email protected]>
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/device.h | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index 54c6383..ce1587a 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -179,10 +179,9 @@ struct vnt_usb_send_context {
void *pDevice;
struct sk_buff *pPacket;
struct urb *pUrb;
+ struct ethhdr sEthHeader;
unsigned int uBufLen;
u8 type;
- struct ethhdr sEthHeader;
- void *Next;
bool bBoolInUse;
unsigned char Data[MAX_TOTAL_SIZE_WITH_ALL_HEADERS];
};
--
1.9.0
added Joe's cc
On 25/02/14 20:51, Malcolm Priestley wrote:
> Remove unnecessary cast to void * urb->context
>
> Reported-by: Joe Perches <[email protected]>
> Signed-off-by: Malcolm Priestley <[email protected]>
> ---
> drivers/staging/vt6656/usbpipe.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
> index 1477def..54c68a5 100644
> --- a/drivers/staging/vt6656/usbpipe.c
> +++ b/drivers/staging/vt6656/usbpipe.c
> @@ -347,7 +347,7 @@ int PIPEnsInterruptRead(struct vnt_private *priv)
>
> static void s_nsInterruptUsbIoCompleteRead(struct urb *urb)
> {
> - struct vnt_private *priv = (struct vnt_private *)urb->context;
> + struct vnt_private *priv = urb->context;
> int status;
>
> DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
> @@ -465,7 +465,7 @@ int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb)
>
> static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
> {
> - struct vnt_rcb *rcb = (struct vnt_rcb *)urb->context;
> + struct vnt_rcb *rcb = urb->context;
> struct vnt_private *priv = rcb->pDevice;
> int re_alloc_skb = false;
>
> @@ -592,8 +592,7 @@ int PIPEnsSendBulkOut(struct vnt_private *priv,
>
> static void s_nsBulkOutIoCompleteWrite(struct urb *urb)
> {
> - struct vnt_usb_send_context *context =
> - (struct vnt_usb_send_context *)urb->context;
> + struct vnt_usb_send_context *context = urb->context;
> struct vnt_private *priv = context->pDevice;
> u8 context_type = context->type;
> unsigned long buf_len = context->uBufLen;
>
Just use urb->status directly.
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 9a922b4..2f8e8e6 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -472,15 +472,14 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
unsigned long bytesRead;
int bIndicateReceive = false;
int bReAllocSkb = false;
- int status;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n");
- status = urb->status;
+
bytesRead = urb->actual_length;
- if (status) {
+ if (urb->status) {
pDevice->ulBulkInError++;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK In failed %d\n", status);
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK In failed %d\n", urb->status);
//todo...xxxxxx
// if (status == USBD_STATUS_CRC) {
// pDevice->ulBulkInContCRCError++;
--
1.9.0
Replace with urb->actual_length.
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 2f8e8e6..87601b7 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -469,14 +469,10 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
{
struct vnt_rcb *pRCB = (struct vnt_rcb *)urb->context;
struct vnt_private *pDevice = pRCB->pDevice;
- unsigned long bytesRead;
- int bIndicateReceive = false;
int bReAllocSkb = false;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n");
- bytesRead = urb->actual_length;
-
if (urb->status) {
pDevice->ulBulkInError++;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"BULK In failed %d\n", urb->status);
@@ -489,15 +485,13 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
// MP_SET_FLAG(pDevice, fMP_DISCONNECTED);
// }
} else {
- if (bytesRead)
- bIndicateReceive = true;
pDevice->ulBulkInContCRCError = 0;
- pDevice->ulBulkInBytesRead += bytesRead;
+ pDevice->ulBulkInBytesRead += urb->actual_length;
}
- if (bIndicateReceive) {
+ if (urb->actual_length) {
spin_lock(&pDevice->lock);
- if (RXbBulkInProcessData(pDevice, pRCB, bytesRead) == true)
+ if (RXbBulkInProcessData(pDevice, pRCB, urb->actual_length) == true)
bReAllocSkb = true;
spin_unlock(&pDevice->lock);
}
--
1.9.0
Remove camel case and white space.
Camel case changes
pDevice -> priv
pRCB -> rcb
ntStatus -> status
pUrb -> urb
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 52 +++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 27 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 8092c9a..1477def 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -409,45 +409,43 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb)
*
*/
-int PIPEnsBulkInUsbRead(struct vnt_private *pDevice, struct vnt_rcb *pRCB)
+int PIPEnsBulkInUsbRead(struct vnt_private *priv, struct vnt_rcb *rcb)
{
- int ntStatus = 0;
- struct urb *pUrb;
+ int status = 0;
+ struct urb *urb;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsStartBulkInUsbRead\n");
- if (pDevice->Flags & fMP_DISCONNECTED)
- return STATUS_FAILURE;
+ if (priv->Flags & fMP_DISCONNECTED)
+ return STATUS_FAILURE;
- pDevice->ulBulkInPosted++;
+ priv->ulBulkInPosted++;
- pUrb = pRCB->pUrb;
- //
- // Now that we have created the urb, we will send a
- // request to the USB device object.
- //
- if (pRCB->skb == NULL) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"pRCB->skb is null \n");
- return ntStatus;
- }
+ urb = rcb->pUrb;
+ if (rcb->skb == NULL) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"rcb->skb is null\n");
+ return status;
+ }
- usb_fill_bulk_urb(pUrb,
- pDevice->usb,
- usb_rcvbulkpipe(pDevice->usb, 2),
- (void *) (pRCB->skb->data),
+ usb_fill_bulk_urb(urb,
+ priv->usb,
+ usb_rcvbulkpipe(priv->usb, 2),
+ (void *) (rcb->skb->data),
MAX_TOTAL_SIZE_WITH_ALL_HEADERS,
s_nsBulkInUsbIoCompleteRead,
- pRCB);
+ rcb);
- ntStatus = usb_submit_urb(pUrb, GFP_ATOMIC);
- if (ntStatus != 0) {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Rx URB failed %d\n", ntStatus);
+ status = usb_submit_urb(urb, GFP_ATOMIC);
+ if (status != 0) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+ "Submit Rx URB failed %d\n", status);
return STATUS_FAILURE ;
}
- pRCB->Ref = 1;
- pRCB->bBoolInUse= true;
- return ntStatus;
+ rcb->Ref = 1;
+ rcb->bBoolInUse = true;
+
+ return status;
}
/*
--
1.9.0
Clean up white space and camel case.
Camel case changes
pDevice -> priv
pRCB -> rcb
bReAllocSkb -> re_alloc_skb
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 49 ++++++++++++++++++++++------------------
1 file changed, 27 insertions(+), 22 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 1cab7a3..8092c9a 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -467,16 +467,16 @@ int PIPEnsBulkInUsbRead(struct vnt_private *pDevice, struct vnt_rcb *pRCB)
static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
{
- struct vnt_rcb *pRCB = (struct vnt_rcb *)urb->context;
- struct vnt_private *pDevice = pRCB->pDevice;
- int bReAllocSkb = false;
+ struct vnt_rcb *rcb = (struct vnt_rcb *)urb->context;
+ struct vnt_private *priv = rcb->pDevice;
+ int re_alloc_skb = false;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"---->s_nsBulkInUsbIoCompleteRead\n");
switch (urb->status) {
case 0:
- pDevice->ulBulkInContCRCError = 0;
- pDevice->ulBulkInBytesRead += urb->actual_length;
+ priv->ulBulkInContCRCError = 0;
+ priv->ulBulkInBytesRead += urb->actual_length;
break;
case -ECONNRESET:
case -ENOENT:
@@ -484,28 +484,33 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
return;
case -ETIMEDOUT:
default:
- pDevice->ulBulkInError++;
+ priv->ulBulkInError++;
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
"BULK In failed %d\n", urb->status);
break;
}
- if (urb->actual_length) {
- spin_lock(&pDevice->lock);
- if (RXbBulkInProcessData(pDevice, pRCB, urb->actual_length) == true)
- bReAllocSkb = true;
- spin_unlock(&pDevice->lock);
- }
- pRCB->Ref--;
- if (pRCB->Ref == 0)
- {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d \n",pDevice->NumRecvFreeList);
- spin_lock(&pDevice->lock);
- RXvFreeRCB(pRCB, bReAllocSkb);
- spin_unlock(&pDevice->lock);
- }
+ if (urb->actual_length) {
+ spin_lock(&priv->lock);
+
+ if (RXbBulkInProcessData(priv, rcb, urb->actual_length) == true)
+ re_alloc_skb = true;
+
+ spin_unlock(&priv->lock);
+ }
- return;
+ rcb->Ref--;
+ if (rcb->Ref == 0) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"RxvFreeNormal %d\n",
+ priv->NumRecvFreeList);
+ spin_lock(&priv->lock);
+
+ RXvFreeRCB(rcb, re_alloc_skb);
+
+ spin_unlock(&priv->lock);
+ }
+
+ return;
}
/*
--
1.9.0
Remove commented out code, white space and camel case.
camel case changes
pDevice -> priv
pContext -> context
pUrb -> urb
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 61 +++++++++++++++++-----------------------
1 file changed, 26 insertions(+), 35 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 706c163..9a922b4 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -528,50 +528,41 @@ static void s_nsBulkInUsbIoCompleteRead(struct urb *urb)
*
*/
-int PIPEnsSendBulkOut(struct vnt_private *pDevice,
- struct vnt_usb_send_context *pContext)
+int PIPEnsSendBulkOut(struct vnt_private *priv,
+ struct vnt_usb_send_context *context)
{
int status;
- struct urb *pUrb;
+ struct urb *urb;
- pDevice->bPWBitOn = false;
+ priv->bPWBitOn = false;
-/*
- if (pDevice->pPendingBulkOutContext != NULL) {
- pDevice->NumContextsQueued++;
- EnqueueContext(pDevice->FirstTxContextQueue, pDevice->LastTxContextQueue, pContext);
- status = STATUS_PENDING;
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Send pending!\n");
- return status;
- }
-*/
-
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n");
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"s_nsSendBulkOut\n");
- if (!(MP_IS_READY(pDevice) && pDevice->Flags & fMP_POST_WRITES)) {
- pContext->bBoolInUse = false;
+ if (!(MP_IS_READY(priv) && priv->Flags & fMP_POST_WRITES)) {
+ context->bBoolInUse = false;
return STATUS_RESOURCES;
}
- pUrb = pContext->pUrb;
- pDevice->ulBulkOutPosted++;
-// pDevice->pPendingBulkOutContext = pContext;
- usb_fill_bulk_urb(pUrb,
- pDevice->usb,
- usb_sndbulkpipe(pDevice->usb, 3),
- pContext->Data,
- pContext->uBufLen,
+ urb = context->pUrb;
+ priv->ulBulkOutPosted++;
+
+ usb_fill_bulk_urb(urb,
+ priv->usb,
+ usb_sndbulkpipe(priv->usb, 3),
+ context->Data,
+ context->uBufLen,
s_nsBulkOutIoCompleteWrite,
- pContext);
-
- status = usb_submit_urb(pUrb, GFP_ATOMIC);
- if (status != 0)
- {
- DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"Submit Tx URB failed %d\n", status);
- pContext->bBoolInUse = false;
- return STATUS_FAILURE;
- }
- return STATUS_PENDING;
+ context);
+
+ status = usb_submit_urb(urb, GFP_ATOMIC);
+ if (status != 0) {
+ DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
+ "Submit Tx URB failed %d\n", status);
+ context->bBoolInUse = false;
+ return STATUS_FAILURE;
+ }
+
+ return STATUS_PENDING;
}
/*
--
1.9.0
Signed-off-by: Malcolm Priestley <[email protected]>
---
drivers/staging/vt6656/usbpipe.c | 15 +++++++--------
1 file changed, 7 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index a93d0ff..706c163 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -556,14 +556,13 @@ int PIPEnsSendBulkOut(struct vnt_private *pDevice,
pUrb = pContext->pUrb;
pDevice->ulBulkOutPosted++;
// pDevice->pPendingBulkOutContext = pContext;
- usb_fill_bulk_urb(
- pUrb,
- pDevice->usb,
- usb_sndbulkpipe(pDevice->usb, 3),
- (void *) &(pContext->Data[0]),
- pContext->uBufLen,
- s_nsBulkOutIoCompleteWrite,
- pContext);
+ usb_fill_bulk_urb(pUrb,
+ pDevice->usb,
+ usb_sndbulkpipe(pDevice->usb, 3),
+ pContext->Data,
+ pContext->uBufLen,
+ s_nsBulkOutIoCompleteWrite,
+ pContext);
status = usb_submit_urb(pUrb, GFP_ATOMIC);
if (status != 0)
--
1.9.0