summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-09-09 10:00:16 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-09-09 10:00:16 -0600
commit4425b0261bfdcd4cf8765917dc2b3a8b0d80c177 (patch)
treebfd39a8d3439e9bd78c11cc926b4a6b05cc75c95
parent8b5a8f98e261f31f15cae44fe8847ada4a0654e0 (diff)
downloadnuttx-4425b0261bfdcd4cf8765917dc2b3a8b0d80c177.tar.gz
nuttx-4425b0261bfdcd4cf8765917dc2b3a8b0d80c177.tar.bz2
nuttx-4425b0261bfdcd4cf8765917dc2b3a8b0d80c177.zip
USB MSC host class driver: Don't bother retrying to initialize the FLASH if the interface is returning fatal transfer errors
-rw-r--r--nuttx/ChangeLog4
-rw-r--r--nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c2
-rw-r--r--nuttx/arch/arm/src/sama5/sam_ohci.c2
-rw-r--r--nuttx/drivers/usbhost/usbhost_storage.c14
4 files changed, 20 insertions, 2 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index e08ce2653..9be16a33a 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -5522,4 +5522,8 @@
(2013-9-6).
* drivers/usbdev/usbmsc_desc.c: Fix a warning when USB MSC is
compiled for a high-speed device (2013-9-7).
+ * drivers/usbhost/usbhost_storage.c: If device is returning fatal
+ transfer errors while attempt to initialize, don't bother with
+ the startup retries; abort immediately so that the device will
+ be reset and we can try again (2013-9-9).
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
index 08bc9df8b..fc4f4e92c 100644
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_usbhost.c
@@ -1304,7 +1304,7 @@ static int lpc17_ctrltd(struct lpc17_usbhost_s *priv, uint32_t dirpid,
else
{
uvdbg("Bad TD completion status: %d\n", EDCTRL->tdstatus);
- ret = -EIO;
+ ret = ed->tdstatus == TD_CC_STALL ? -EPERM : -EIO;
}
}
diff --git a/nuttx/arch/arm/src/sama5/sam_ohci.c b/nuttx/arch/arm/src/sama5/sam_ohci.c
index d943d01d9..a59d441b0 100644
--- a/nuttx/arch/arm/src/sama5/sam_ohci.c
+++ b/nuttx/arch/arm/src/sama5/sam_ohci.c
@@ -2991,7 +2991,7 @@ static int sam_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
else
{
udbg("ERROR: Bad TD completion status: %d\n", ed->tdstatus);
- ret = -EIO;
+ ret = ed->tdstatus == TD_CC_STALL ? -EPERM : -EIO;
}
}
diff --git a/nuttx/drivers/usbhost/usbhost_storage.c b/nuttx/drivers/usbhost/usbhost_storage.c
index d72203bdf..c6126131f 100644
--- a/nuttx/drivers/usbhost/usbhost_storage.c
+++ b/nuttx/drivers/usbhost/usbhost_storage.c
@@ -1248,6 +1248,19 @@ static inline int usbhost_initvolume(FAR struct usbhost_state_s *priv)
uvdbg("Request sense\n");
ret = usbhost_requestsense(priv);
}
+
+ /* It is acceptable for a mass storage device to respond to the
+ * Test Unit Ready and Request Sense commands with a stall if it is
+ * unable to respond. But other failures mean that something is
+ * wrong and a device reset is in order. The transfer functions will
+ * return -EPERM if the transfer failed due to a stall.
+ */
+
+ if (ret < 0 && ret != -EPERM)
+ {
+ udbg("ERROR: DRVR_TRANSFER returned: %d\n", ret);
+ break;
+ }
}
/* Did the unit become ready? Did an error occur? Or did we time out? */
@@ -1569,6 +1582,7 @@ static inline int usbhost_tfree(FAR struct usbhost_state_s *priv)
priv->tbuffer = NULL;
priv->tbuflen = 0;
}
+
return result;
}