mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 21:36:28 +08:00
EHCI HCDs: Check for transfer in progress before attempting cancellation
This commit is contained in:
@@ -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:
|
||||||
|
|||||||
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user