Commit 7021b684 authored by Malcolm Priestley's avatar Malcolm Priestley Committed by Greg Kroah-Hartman

staging: vt6656: usbpipe.c PIPEnsControlOut use usb_control_msg

Now that this fucntion is nolonger atomic change to usb_control_msg

Return STATUS_FAILURE if ntStatus less than wLength.

Remove fMP_CONTROL_WRITES flag
Signed-off-by: default avatarMalcolm Priestley <tvboxspy@gmail.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3c647642
...@@ -744,7 +744,6 @@ struct vnt_private { ...@@ -744,7 +744,6 @@ struct vnt_private {
#define fMP_POST_READS 0x00000100 #define fMP_POST_READS 0x00000100
#define fMP_POST_WRITES 0x00000200 #define fMP_POST_WRITES 0x00000200
#define fMP_CONTROL_READS 0x00000400 #define fMP_CONTROL_READS 0x00000400
#define fMP_CONTROL_WRITES 0x00000800
#define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F)) #define MP_SET_FLAG(_M, _F) ((_M)->Flags |= (_F))
#define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F)) #define MP_CLEAR_FLAG(_M, _F) ((_M)->Flags &= ~(_F))
......
...@@ -965,7 +965,6 @@ static int device_open(struct net_device *dev) ...@@ -965,7 +965,6 @@ static int device_open(struct net_device *dev)
MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED); MP_CLEAR_FLAG(pDevice, fMP_DISCONNECTED);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS); MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
MP_SET_FLAG(pDevice, fMP_POST_READS); MP_SET_FLAG(pDevice, fMP_POST_READS);
MP_SET_FLAG(pDevice, fMP_POST_WRITES); MP_SET_FLAG(pDevice, fMP_POST_WRITES);
......
...@@ -64,7 +64,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb); ...@@ -64,7 +64,6 @@ static void s_nsInterruptUsbIoCompleteRead(struct urb *urb);
static void s_nsBulkInUsbIoCompleteRead(struct urb *urb); static void s_nsBulkInUsbIoCompleteRead(struct urb *urb);
static void s_nsBulkOutIoCompleteWrite(struct urb *urb); static void s_nsBulkOutIoCompleteWrite(struct urb *urb);
static void s_nsControlInUsbIoCompleteRead(struct urb *urb); static void s_nsControlInUsbIoCompleteRead(struct urb *urb);
static void s_nsControlInUsbIoCompleteWrite(struct urb *urb);
int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer) u16 wValue, u16 wIndex, u16 wLength, u8 *pbyBuffer)
...@@ -74,9 +73,6 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, ...@@ -74,9 +73,6 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
if (pDevice->Flags & fMP_DISCONNECTED) if (pDevice->Flags & fMP_DISCONNECTED)
return STATUS_FAILURE; return STATUS_FAILURE;
if (pDevice->Flags & fMP_CONTROL_WRITES)
return STATUS_FAILURE;
if (in_interrupt()) { if (in_interrupt()) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest); DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"in_interrupt return ..byRequest %x\n", byRequest);
return STATUS_FAILURE; return STATUS_FAILURE;
...@@ -109,67 +105,22 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest, ...@@ -109,67 +105,22 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue, int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
u16 wIndex, u16 wLength, u8 *pbyBuffer) u16 wIndex, u16 wLength, u8 *pbyBuffer)
__releases(&pDevice->lock)
__acquires(&pDevice->lock)
{ {
int ntStatus = 0; int ntStatus = 0;
int ii;
if (pDevice->Flags & fMP_DISCONNECTED) if (pDevice->Flags & fMP_DISCONNECTED)
return STATUS_FAILURE; return STATUS_FAILURE;
if (pDevice->Flags & fMP_CONTROL_WRITES)
return STATUS_FAILURE;
if (pDevice->Flags & fMP_CONTROL_READS)
return STATUS_FAILURE;
if (pDevice->pControlURB->hcpriv)
return STATUS_FAILURE;
mutex_lock(&pDevice->usb_lock); mutex_lock(&pDevice->usb_lock);
MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES); ntStatus = usb_control_msg(pDevice->usb,
usb_sndctrlpipe(pDevice->usb, 0), byRequest, 0x40, wValue,
pDevice->sUsbCtlRequest.bRequestType = 0x40; wIndex, pbyBuffer, wLength, USB_CTL_WAIT);
pDevice->sUsbCtlRequest.bRequest = byRequest;
pDevice->sUsbCtlRequest.wValue = cpu_to_le16p(&wValue);
pDevice->sUsbCtlRequest.wIndex = cpu_to_le16p(&wIndex);
pDevice->sUsbCtlRequest.wLength = cpu_to_le16p(&wLength);
pDevice->pControlURB->transfer_flags |= URB_ASYNC_UNLINK;
pDevice->pControlURB->actual_length = 0;
// Notice, pbyBuffer limited point to variable buffer, can't be constant.
usb_fill_control_urb(pDevice->pControlURB, pDevice->usb,
usb_sndctrlpipe(pDevice->usb , 0), (char *) &pDevice->sUsbCtlRequest,
pbyBuffer, wLength, s_nsControlInUsbIoCompleteWrite, pDevice);
ntStatus = usb_submit_urb(pDevice->pControlURB, GFP_ATOMIC);
if (ntStatus != 0) {
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
"control send request submission failed: %d\n",
ntStatus);
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
mutex_unlock(&pDevice->usb_lock); mutex_unlock(&pDevice->usb_lock);
return STATUS_FAILURE;
}
for (ii = 0; ii <= USB_CTL_WAIT; ii ++) {
if (pDevice->Flags & fMP_CONTROL_WRITES) if (ntStatus < (int)wLength)
mdelay(1);
else
break;
if (ii >= USB_CTL_WAIT) {
DBG_PRT(MSG_LEVEL_DEBUG,
KERN_INFO "control send request submission timeout\n");
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
mutex_unlock(&pDevice->usb_lock);
return STATUS_FAILURE; return STATUS_FAILURE;
}
}
mutex_unlock(&pDevice->usb_lock);
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
...@@ -188,9 +139,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, ...@@ -188,9 +139,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
if (pDevice->Flags & fMP_CONTROL_READS) if (pDevice->Flags & fMP_CONTROL_READS)
return STATUS_FAILURE; return STATUS_FAILURE;
if (pDevice->Flags & fMP_CONTROL_WRITES)
return STATUS_FAILURE;
if (pDevice->pControlURB->hcpriv) if (pDevice->pControlURB->hcpriv)
return STATUS_FAILURE; return STATUS_FAILURE;
...@@ -239,27 +187,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue, ...@@ -239,27 +187,6 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
return ntStatus; return ntStatus;
} }
static void s_nsControlInUsbIoCompleteWrite(struct urb *urb)
{
struct vnt_private *pDevice = (struct vnt_private *)urb->context;
pDevice = urb->context;
switch (urb->status) {
case 0:
break;
case -EINPROGRESS:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status EINPROGRESS%d\n", urb->status);
break;
case -ENOENT:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status ENOENT %d\n", urb->status);
break;
default:
DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"ctrl write urb status %d\n", urb->status);
}
MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
}
/* /*
* Description: * Description:
* Complete function of usb Control callback * Complete function of usb Control callback
......
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