linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Malcolm Priestley <tvboxspy@gmail.com>
To: gregkh@linuxfoundation.org
Cc: linux-wireless@vger.kernel.org, Malcolm Priestley <tvboxspy@gmail.com>
Subject: [PATCH 08/13] staging: vt6656: lock changes: usbpipe.c add mutex lock
Date: Sat,  3 May 2014 15:17:29 +0100	[thread overview]
Message-ID: <1399126654-2663-8-git-send-email-tvboxspy@gmail.com> (raw)
In-Reply-To: <1399126654-2663-1-git-send-email-tvboxspy@gmail.com>

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>
---
 drivers/staging/vt6656/device.h   |  1 +
 drivers/staging/vt6656/main_usb.c |  2 ++
 drivers/staging/vt6656/usbpipe.c  | 16 ++++++++++++++++
 3 files changed, 19 insertions(+)

diff --git a/drivers/staging/vt6656/device.h b/drivers/staging/vt6656/device.h
index f36a2eb..622cf02 100644
--- a/drivers/staging/vt6656/device.h
+++ b/drivers/staging/vt6656/device.h
@@ -363,6 +363,7 @@ struct vnt_private {
 	u8 byRxMode;
 
 	spinlock_t lock;
+	struct mutex usb_lock;
 
 	u32 rx_bytes;
 
diff --git a/drivers/staging/vt6656/main_usb.c b/drivers/staging/vt6656/main_usb.c
index e99d2a9..14e649a 100644
--- a/drivers/staging/vt6656/main_usb.c
+++ b/drivers/staging/vt6656/main_usb.c
@@ -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);
diff --git a/drivers/staging/vt6656/usbpipe.c b/drivers/staging/vt6656/usbpipe.c
index 836da00..934d0a9 100644
--- a/drivers/staging/vt6656/usbpipe.c
+++ b/drivers/staging/vt6656/usbpipe.c
@@ -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;
 }
 
-- 
1.9.1


  parent reply	other threads:[~2014-05-03 14:19 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-03 14:17 [PATCH 01/13] staging: vt6656: lock changes: Remove spin locks Malcolm Priestley
2014-05-03 14:17 ` [PATCH 02/13] staging: vt6656: lock changes: vRunCommand remove locks Malcolm Priestley
2014-05-03 14:17 ` [PATCH 03/13] staging: vt6656: lock changes: RXvMngWorkItem Malcolm Priestley
2014-05-03 14:17 ` [PATCH 04/13] staging: vt6656: lock changes: csMgmt_xmit Malcolm Priestley
2014-05-03 14:17 ` [PATCH 05/13] staging: vt6656: lock changes: vDMA0_tx_80211 Malcolm Priestley
2014-05-03 14:17 ` [PATCH 06/13] staging: vt6656: lock changes: bMgrPrepareBeaconToSend add lock Malcolm Priestley
2014-05-03 14:17 ` [PATCH 07/13] staging: vt6656: lock changes: vRunCommand nsDMA_tx_packet Malcolm Priestley
2014-05-03 14:17 ` Malcolm Priestley [this message]
2014-05-03 14:17 ` [PATCH 09/13] staging: vt6656: lock changes: s_nsBulkInUsbIoCompleteRead Malcolm Priestley
2014-05-03 14:17 ` [PATCH 10/13] staging: vt6656: lock changes device_xmit Malcolm Priestley
2014-05-03 14:17 ` [PATCH 11/13] staging: vt6656: usbpipe.c PIPEnsControlOut use usb_control_msg Malcolm Priestley
2014-05-03 14:17 ` [PATCH 12/13] staging: vt6656: PIPEnsControlIn " Malcolm Priestley
2014-05-03 14:17 ` [PATCH 13/13] staging: vt6656: Remove PIPEnsControlOutAsyn/CONTROLnsRequestOutAsyn Malcolm Priestley
2014-05-15 20:31 ` [PATCH 01/13] staging: vt6656: lock changes: Remove spin locks Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1399126654-2663-8-git-send-email-tvboxspy@gmail.com \
    --to=tvboxspy@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).