staging: vt6656: lock changes: usbpipe.c add mutex lock.
authorMalcolm Priestley <tvboxspy@gmail.com>
Thu, 15 May 2014 21:49:19 +0000 (22:49 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 15 May 2014 22:02:19 +0000 (15:02 -0700)
PIPEnsControlOut and PIPEnsControlIn are nolonger
atomic but they do need a usb lock.

Add new mutex lock for these functions and PIPEnsControlOutAsyn.

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

index f36a2eb826b71e326649f7cac1e2c685875c22f4..622cf02f5c8adf9415242eedd219014b49350983 100644 (file)
@@ -363,6 +363,7 @@ struct vnt_private {
        u8 byRxMode;
 
        spinlock_t lock;
+       struct mutex usb_lock;
 
        u32 rx_bytes;
 
index e99d2a9378a52e5c7a2ccbf8ed7f896f48525cb6..14e649a66beba82165fb3b425cb5635777ba45ba 100644 (file)
@@ -695,6 +695,8 @@ vt6656_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
        device_set_options(pDevice);
        spin_lock_init(&pDevice->lock);
+       mutex_init(&pDevice->usb_lock);
+
        INIT_DELAYED_WORK(&pDevice->run_command_work, vRunCommand);
        INIT_DELAYED_WORK(&pDevice->second_callback_work, BSSvSecondCallBack);
        INIT_WORK(&pDevice->read_work_item, RXvWorkItem);
index 836da00bfaac192331ff01b79f17d20c81d4580f..934d0a92363b0e939ecbe062b16edb4b3a5cccea 100644 (file)
@@ -82,6 +82,8 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
         return STATUS_FAILURE;
     }
 
+       mutex_lock(&pDevice->usb_lock);
+
     ntStatus = usb_control_msg(
                             pDevice->usb,
                             usb_sndctrlpipe(pDevice->usb , 0),
@@ -100,6 +102,8 @@ int PIPEnsControlOutAsyn(struct vnt_private *pDevice, u8 byRequest,
         DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO"usb_sndctrlpipe fail, ntStatus= %d\n", ntStatus);
     }
 
+       mutex_unlock(&pDevice->usb_lock);
+
     return ntStatus;
 }
 
@@ -123,6 +127,8 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
        if (pDevice->pControlURB->hcpriv)
                return STATUS_FAILURE;
 
+       mutex_lock(&pDevice->usb_lock);
+
        MP_SET_FLAG(pDevice, fMP_CONTROL_WRITES);
 
        pDevice->sUsbCtlRequest.bRequestType = 0x40;
@@ -143,6 +149,7 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
                        "control send request submission failed: %d\n",
                                ntStatus);
                MP_CLEAR_FLAG(pDevice, fMP_CONTROL_WRITES);
+               mutex_unlock(&pDevice->usb_lock);
                return STATUS_FAILURE;
        }
 
@@ -157,10 +164,13 @@ int PIPEnsControlOut(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
                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;
         }
     }
 
+       mutex_unlock(&pDevice->usb_lock);
+
     return STATUS_SUCCESS;
 }
 
@@ -184,6 +194,8 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
        if (pDevice->pControlURB->hcpriv)
                return STATUS_FAILURE;
 
+       mutex_lock(&pDevice->usb_lock);
+
        MP_SET_FLAG(pDevice, fMP_CONTROL_READS);
 
        pDevice->sUsbCtlRequest.bRequestType = 0xC0;
@@ -202,6 +214,7 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
                DBG_PRT(MSG_LEVEL_DEBUG, KERN_INFO
                        "control request submission failed: %d\n", ntStatus);
                MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
+               mutex_unlock(&pDevice->usb_lock);
                return STATUS_FAILURE;
        }
 
@@ -216,10 +229,13 @@ int PIPEnsControlIn(struct vnt_private *pDevice, u8 byRequest, u16 wValue,
                DBG_PRT(MSG_LEVEL_DEBUG,
                        KERN_INFO "control rcv request submission timeout\n");
             MP_CLEAR_FLAG(pDevice, fMP_CONTROL_READS);
+           mutex_unlock(&pDevice->usb_lock);
             return STATUS_FAILURE;
         }
     }
 
+       mutex_unlock(&pDevice->usb_lock);
+
     return ntStatus;
 }