diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-10-28 17:20:09 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-10-28 17:20:09 +0000 |
commit | b038e9081472b51f9493c4c7787c3280431ccac1 (patch) | |
tree | 686b0d68effb3473fe534e068b6f779a26a2940c /nuttx/drivers/usbdev/usbdev_scsi.c | |
parent | ebc1ad6b38a9f4427790c9ded5a4a81248c1d35d (diff) | |
download | px4-nuttx-b038e9081472b51f9493c4c7787c3280431ccac1.tar.gz px4-nuttx-b038e9081472b51f9493c4c7787c3280431ccac1.tar.bz2 px4-nuttx-b038e9081472b51f9493c4c7787c3280431ccac1.zip |
Don't send final packet if length is zero
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1093 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/usbdev/usbdev_scsi.c')
-rw-r--r-- | nuttx/drivers/usbdev/usbdev_scsi.c | 47 |
1 files changed, 27 insertions, 20 deletions
diff --git a/nuttx/drivers/usbdev/usbdev_scsi.c b/nuttx/drivers/usbdev/usbdev_scsi.c index 6cc997d2f..1f169332b 100644 --- a/nuttx/drivers/usbdev/usbdev_scsi.c +++ b/nuttx/drivers/usbdev/usbdev_scsi.c @@ -714,7 +714,7 @@ static int inline usbstrg_cmdmodesense6(FAR struct usbstrg_dev_s *priv, * * (1) A MODESENSE6-specific mode parameter header, * (2) A variable length list of block descriptors, and - * (3) A variable lengtth list of mode page formats + * (3) A variable length list of mode page formats */ mph->type = 0; /* Medium type */ @@ -1743,7 +1743,7 @@ static int usbstrg_cmdparsestate(FAR struct usbstrg_dev_s *priv) break; /* * 0x20-22 Vendor specific */ - case SCSI_CMD_READFORMATCAPACITIES: /* 0x23 Vendor-specific */ + case SCSI_CMD_READFORMATCAPACITIES: /* 0x23 Vendor-specific (defined in MMC spec) */ ret = usbstrg_cmdreadformatcapacity(priv, buf); break; /* * 0x24 Vendor specific */ @@ -2262,29 +2262,36 @@ static int usbstrg_cmdfinishstate(FAR struct usbstrg_dev_s *priv) case USBSTRG_FLAGS_DIRDEVICE2HOST: if (priv->cbwlen > 0) { - struct usbdev_req_s *req; - - /* Take a request from the wrreqlist (we've already checked - * that is it not NULL) + /* On most commands (the exception is outgoing, write commands), + * the data has not not yet been sent. */ - flags = irqsave(); - privreq = (FAR struct usbstrg_req_s *)sq_remfirst(&priv->wrreqlist); - irqrestore(flags); + if (priv->nreqbytes > 0) + { + struct usbdev_req_s *req; - /* Send the write request */ + /* Take a request from the wrreqlist (we've already checked + * that is it not NULL) + */ - req = privreq->req; - req->len = priv->nreqbytes; - req->callback = usbstrg_wrcomplete; - req->private = privreq; - req->flags = USBDEV_REQFLAGS_NULLPKT; + flags = irqsave(); + privreq = (FAR struct usbstrg_req_s *)sq_remfirst(&priv->wrreqlist); + irqrestore(flags); - ret = EP_SUBMIT(priv->epbulkin, privreq->req); - if (ret < 0) - { - usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSUBMIT), (uint16)-ret); - } + /* Send the write request */ + + req = privreq->req; + req->len = priv->nreqbytes; + req->callback = usbstrg_wrcomplete; + req->private = privreq; + req->flags = USBDEV_REQFLAGS_NULLPKT; + + ret = EP_SUBMIT(priv->epbulkin, privreq->req); + if (ret < 0) + { + usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CMDFINISHSUBMIT), (uint16)-ret); + } + } /* Stall the BULK In endpoint if there is a residue */ |