USB MSC host class driver: Don't bother retrying to initialize the FLASH if the interface is returning fatal transfer errors

This commit is contained in:
Gregory Nutt 2013-09-09 10:00:16 -06:00
parent 40f84dfa19
commit a992004b0e
4 changed files with 20 additions and 2 deletions

View File

@ -5522,4 +5522,8 @@
(2013-9-6). (2013-9-6).
* drivers/usbdev/usbmsc_desc.c: Fix a warning when USB MSC is * drivers/usbdev/usbmsc_desc.c: Fix a warning when USB MSC is
compiled for a high-speed device (2013-9-7). 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).

View File

@ -1304,7 +1304,7 @@ static int lpc17_ctrltd(struct lpc17_usbhost_s *priv, uint32_t dirpid,
else else
{ {
uvdbg("Bad TD completion status: %d\n", EDCTRL->tdstatus); uvdbg("Bad TD completion status: %d\n", EDCTRL->tdstatus);
ret = -EIO; ret = ed->tdstatus == TD_CC_STALL ? -EPERM : -EIO;
} }
} }

View File

@ -2991,7 +2991,7 @@ static int sam_transfer(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep,
else else
{ {
udbg("ERROR: Bad TD completion status: %d\n", ed->tdstatus); udbg("ERROR: Bad TD completion status: %d\n", ed->tdstatus);
ret = -EIO; ret = ed->tdstatus == TD_CC_STALL ? -EPERM : -EIO;
} }
} }

View File

@ -1248,6 +1248,19 @@ static inline int usbhost_initvolume(FAR struct usbhost_state_s *priv)
uvdbg("Request sense\n"); uvdbg("Request sense\n");
ret = usbhost_requestsense(priv); 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? */ /* 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->tbuffer = NULL;
priv->tbuflen = 0; priv->tbuflen = 0;
} }
return result; return result;
} }