summaryrefslogtreecommitdiff
path: root/nuttx/drivers/usbdev
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-10-27 16:41:12 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-10-27 16:41:12 +0000
commit802835b705971be113b05966aabb02ac7064ee2f (patch)
tree41b7284ece83df9f6d6e63274d1c2abed250af49 /nuttx/drivers/usbdev
parent2327e33b3fb751074e08a53bf6b1892b8fcf340e (diff)
downloadpx4-nuttx-802835b705971be113b05966aabb02ac7064ee2f.tar.gz
px4-nuttx-802835b705971be113b05966aabb02ac7064ee2f.tar.bz2
px4-nuttx-802835b705971be113b05966aabb02ac7064ee2f.zip
Finish missing logic
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1084 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/usbdev')
-rw-r--r--nuttx/drivers/usbdev/usbdev_scsi.c97
1 files changed, 44 insertions, 53 deletions
diff --git a/nuttx/drivers/usbdev/usbdev_scsi.c b/nuttx/drivers/usbdev/usbdev_scsi.c
index 726748920..006c6fa5f 100644
--- a/nuttx/drivers/usbdev/usbdev_scsi.c
+++ b/nuttx/drivers/usbdev/usbdev_scsi.c
@@ -2432,7 +2432,7 @@ void *usbstrg_workerthread(void *arg)
/* Then loop until we are asked to terminate */
- while (eventset != USBSTRG_EVENT_TERMINATEREQUEST)
+ while ((eventset & USBSTRG_EVENT_TERMINATEREQUEST) == 0)
{
/* Wait for some interesting event. Note that we must both take the
* lock (to eliminate race conditions with other threads) and disable
@@ -2453,70 +2453,59 @@ void *usbstrg_workerthread(void *arg)
eventset = priv->theventset;
priv->theventset = USBSTRG_EVENT_NOEVENTS;
- irqrestore(flags);
-
- /* Were we awakened by some event that requires immediate action? */
- /* The USBSTRG_EVENT_DISCONNECT is signalled from the disconnect method
- * after all transfers have been stopped, when the host is disconnected.
+ /* Were we awakened by some event that requires immediate action?
+ *
+ * - The USBSTRG_EVENT_DISCONNECT is signalled from the disconnect method
+ * after all transfers have been stopped, when the host is disconnected.
+ *
+ * - The CUSBSTRG_EVENT_RESET is signalled when the bulk-storage-specific
+ * USBSTRG_REQ_MSRESET EP0 setup received. We must stop the current
+ * operation and reinialize state.
+ *
+ * - The USBSTRG_EVENT_CFGCHANGE is signaled when the EP0 setup logic
+ * receives a valid USB_REQ_SETCONFIGURATION request
+ *
+ * - The USBSTRG_EVENT_IFCHANGE is signaled when the EP0 setup logic
+ * receives a valid USB_REQ_SETINTERFACE request
+ *
+ * - The USBSTRG_EVENT_ABORTBULKOUT event is signalled by the CMDFINISH
+ * logic when there is a residue after processing a host-to-device
+ * transfer. We need to discard all incoming request.
+ *
+ * All other events are just wakeup calls and are intended only
+ * drive the state machine.
*/
- if ((eventset & USBSTRG_EVENT_DISCONNECT) != 0)
+ if ((eventset & (USBSTRG_EVENT_DISCONNECT|USBSTRG_EVENT_RESET|USBSTRG_EVENT_CFGCHANGE|
+ USBSTRG_EVENT_IFCHANGE|USBSTRG_EVENT_ABORTBULKOUT)) != 0)
{
-#warning LOGIC needed
- }
+ /* These events require that the current configuration be reset */
- /* Called with the bulk-storage-specific USBSTRG_REQ_MSRESET EP0 setup
- * received. We must stop the current operation and reinialize state.
- */
+ if ((eventset & USBSTRG_EVENT_IFCHANGE) != 0)
+ {
+ usbstrg_resetconfig(priv);
+ }
- if ((eventset & USBSTRG_EVENT_RESET) != 0)
- {
-#warning LOGIC needed
- priv->thstate = USBSTRG_STATE_IDLE;
- usbstrg_deferredresponse(priv, FALSE);
- }
+ /* These events require that a new configuration be established */
- /* The USBSTRG_EVENT_CFGCHANGE is signaled when the EP0 setup
- * logic receives a USB_REQ_SETCONFIGURATION request
- */
+ if ((eventset & (USBSTRG_EVENT_CFGCHANGE|USBSTRG_EVENT_IFCHANGE)) != 0)
+ {
+ usbstrg_setconfig(priv, priv->thvalue);
+ }
- if ((eventset & USBSTRG_EVENT_CFGCHANGE) != 0)
- {
-#warning LOGIC needed
- usbstrg_setconfig(priv, priv->thvalue);
- priv->thstate = USBSTRG_STATE_IDLE;
- usbstrg_deferredresponse(priv, FALSE);
- }
+ /* These events required that we send a deferred EP0 setup response */
- /* The USBSTRG_EVENT_IFCHANGE is signaled when the EP0 setup
- * logic receives a USB_REQ_SETINTERFACE request
- */
- if ((eventset & USBSTRG_EVENT_IFCHANGE) != 0)
- {
-#warning LOGIC needed
- usbstrg_resetconfig(priv);
- usbstrg_setconfig(priv, priv->thvalue);
- priv->thstate = USBSTRG_STATE_IDLE;
- usbstrg_deferredresponse(priv, FALSE);
- }
+ if ((eventset & (USBSTRG_EVENT_RESET|USBSTRG_EVENT_CFGCHANGE|USBSTRG_EVENT_IFCHANGE)) != 0)
+ {
+ usbstrg_deferredresponse(priv, FALSE);
+ }
- /* Set by the CMDFINISH logic when there is a residue after processing
- * a host-to-device transfer. We need to discard all incoming request.
- */
+ /* For all of these events... terminate any transactions in progress */
- if ((eventset & USBSTRG_EVENT_ABORTBULKOUT) != 0)
- {
-#warning LOGIC needed
priv->thstate = USBSTRG_STATE_IDLE;
}
-
- /* All other events are just wakeup calls and are intended only
- * drive the state maching. Remember only the terminate request event...
- * we'll process that at the end of the loop.
- */
-
- eventset &= USBSTRG_EVENT_TERMINATEREQUEST;
+ irqrestore(flags);
/* Loop processing each SCSI command state. Each state handling
* function will do the following:
@@ -2530,7 +2519,7 @@ void *usbstrg_workerthread(void *arg)
* will resume processing in the same state.
*/
- for (ret = OK; ret == OK; )
+ do
{
switch (priv->thstate)
{
@@ -2564,9 +2553,11 @@ void *usbstrg_workerthread(void *arg)
default:
usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_INVALIDSTATE), priv->thstate);
priv->thstate = USBSTRG_STATE_IDLE;
+ ret = OK;
break;
}
}
+ while (ret == OK);
}
/* Transition to the TERMINATED state and exit */