EHCI HCDs: Check for transfer in progress before attempting cancellation

This commit is contained in:
Gregory Nutt
2015-05-11 12:12:19 -06:00
parent cf1ab6baec
commit 3467c30d73
2 changed files with 38 additions and 8 deletions
+19 -4
View File
@@ -4541,6 +4541,18 @@ static int lpc31_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep)
epinfo->arg = NULL; epinfo->arg = NULL;
irqrestore(flags); irqrestore(flags);
/* Bail if there is no transfer in progress for this endpoint */
#ifdef CONFIG_USBHOST_ASYNCH
if (callback == NULL && !iocwait)
#else
if (!iocwait)
#endif
{
ret = OK;
goto errout_with_sem;
}
/* Handle the cancellation according to the type of the transfer */ /* Handle the cancellation according to the type of the transfer */
switch (epinfo->xfrtype) switch (epinfo->xfrtype)
@@ -4623,25 +4635,28 @@ static int lpc31_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep)
exit_terminate: exit_terminate:
epinfo->result = -ESHUTDOWN; epinfo->result = -ESHUTDOWN;
#ifdef CONFIG_USBHOST_ASYNCH
if (iocwait) if (iocwait)
{ {
/* Yes... wake it up */ /* Yes... wake it up */
#ifdef CONFIG_USBHOST_ASYNCH
DEBUGASSERT(callback == NULL); DEBUGASSERT(callback == NULL);
#endif
lpc31_givesem(&epinfo->iocsem); lpc31_givesem(&epinfo->iocsem);
} }
#ifdef CONFIG_USBHOST_ASYNCH
/* No.. Is there a pending asynchronous transfer? */ /* No.. Is there a pending asynchronous transfer? */
else if (callback != NULL) else /* if (callback != NULL) */
{ {
/* Yes.. perform the callback */ /* Yes.. perform the callback */
callback(arg, -ESHUTDOWN); callback(arg, -ESHUTDOWN);
} }
#else
/* Wake up the waiting thread */
sam_givesem(&epinfo->iocsem);
#endif #endif
errout_with_sem: errout_with_sem:
+19 -4
View File
@@ -4359,6 +4359,18 @@ static int sam_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep)
epinfo->iocwait = false; epinfo->iocwait = false;
irqrestore(flags); irqrestore(flags);
/* Bail if there is no transfer in progress for this endpoint */
#ifdef CONFIG_USBHOST_ASYNCH
if (callback == NULL && !iocwait)
#else
if (!iocwait)
#endif
{
ret = OK;
goto errout_with_sem;
}
/* Handle the cancellation according to the type of the transfer */ /* Handle the cancellation according to the type of the transfer */
switch (epinfo->xfrtype) switch (epinfo->xfrtype)
@@ -4441,25 +4453,28 @@ static int sam_cancel(FAR struct usbhost_driver_s *drvr, usbhost_ep_t ep)
exit_terminate: exit_terminate:
epinfo->result = -ESHUTDOWN; epinfo->result = -ESHUTDOWN;
#ifdef CONFIG_USBHOST_ASYNCH
if (iocwait) if (iocwait)
{ {
/* Yes... wake it up */ /* Yes... wake it up */
#ifdef CONFIG_USBHOST_ASYNCH
DEBUGASSERT(callback == NULL); DEBUGASSERT(callback == NULL);
#endif
sam_givesem(&epinfo->iocsem); sam_givesem(&epinfo->iocsem);
} }
#ifdef CONFIG_USBHOST_ASYNCH
/* No.. Is there a pending asynchronous transfer? */ /* No.. Is there a pending asynchronous transfer? */
else if (callback != NULL) else /* if (callback != NULL) */
{ {
/* Yes.. perform the callback */ /* Yes.. perform the callback */
callback(arg, -ESHUTDOWN); callback(arg, -ESHUTDOWN);
} }
#else
/* Wake up the waiting thread */
sam_givesem(&epinfo->iocsem);
#endif #endif
errout_with_sem: errout_with_sem: