summaryrefslogtreecommitdiff
path: root/nuttx/drivers/usbhost
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-01 13:46:34 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-01 13:46:34 +0000
commit6e09d7aab47a47e36f56d9b33bd6e87e96e2af2c (patch)
treed441b9c13a08c4cf3e8ddb63b3f0898d6c7516d1 /nuttx/drivers/usbhost
parent1e3a9d906b5b4b8578bba4e4cf3a7b84de85ce46 (diff)
downloadpx4-nuttx-6e09d7aab47a47e36f56d9b33bd6e87e96e2af2c.tar.gz
px4-nuttx-6e09d7aab47a47e36f56d9b33bd6e87e96e2af2c.tar.bz2
px4-nuttx-6e09d7aab47a47e36f56d9b33bd6e87e96e2af2c.zip
Add bugfixes recommended by Sheref Younan
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3737 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/drivers/usbhost')
-rw-r--r--nuttx/drivers/usbhost/usbhost_storage.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/nuttx/drivers/usbhost/usbhost_storage.c b/nuttx/drivers/usbhost/usbhost_storage.c
index b2a6d8543..8f5864b6d 100644
--- a/nuttx/drivers/usbhost/usbhost_storage.c
+++ b/nuttx/drivers/usbhost/usbhost_storage.c
@@ -669,6 +669,7 @@ static inline int usbhost_maxlunreq(FAR struct usbhost_state_s *priv)
{
FAR struct usb_ctrlreq_s *req = (FAR struct usb_ctrlreq_s *)priv->tbuffer;
DEBUGASSERT(priv && priv->tbuffer);
+ int ret;
/* Request maximum logical unit number. NOTE: On an IN transaction, The
* req and buffer pointers passed to DRVR_CTRLIN may refer to the same
@@ -680,7 +681,17 @@ static inline int usbhost_maxlunreq(FAR struct usbhost_state_s *priv)
req->type = USB_DIR_IN|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE;
req->req = USBSTRG_REQ_GETMAXLUN;
usbhost_putle16(req->len, 1);
- return DRVR_CTRLIN(priv->drvr, req, priv->tbuffer);
+
+ ret = DRVR_CTRLIN(priv->drvr, req, priv->tbuffer);
+ if (ret != OK)
+ {
+ /* Devices that do not support multiple LUNs may stall this command.
+ * On a failure, a single LUN is assumed.
+ */
+
+ *(priv->tbuffer) = 0;
+ }
+ return OK;
}
static inline int usbhost_testunitready(FAR struct usbhost_state_s *priv)
@@ -788,7 +799,7 @@ static inline int usbhost_readcapacity(FAR struct usbhost_state_s *priv)
/* Save the capacity information */
resp = (FAR struct scsiresp_readcapacity10_s *)priv->tbuffer;
- priv->nblocks = usbhost_getbe32(resp->lba);
+ priv->nblocks = usbhost_getbe32(resp->lba) + 1;
priv->blocksize = usbhost_getbe32(resp->blklen);
/* Receive the CSW */