From 1e85cbd2b0abd4e517f6d5893f744feb25e12c73 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 1 Dec 2009 15:28:33 +0000 Subject: [PATCH] Should not returned queued read requests on a reset git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@2294 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/src/stm32/stm32_usbdev.c | 28 ++++++++++++++++------------ drivers/usbdev/usbdev_scsi.c | 10 +++++----- drivers/usbdev/usbdev_storage.c | 6 +++--- 3 files changed, 24 insertions(+), 20 deletions(-) diff --git a/arch/arm/src/stm32/stm32_usbdev.c b/arch/arm/src/stm32/stm32_usbdev.c index d91da82d6b..faad1e024b 100644 --- a/arch/arm/src/stm32/stm32_usbdev.c +++ b/arch/arm/src/stm32/stm32_usbdev.c @@ -418,6 +418,7 @@ static int stm32_wrrequest(struct stm32_usbdev_s *priv, struct stm32_ep_s *privep); static int stm32_rdrequest(struct stm32_usbdev_s *priv, struct stm32_ep_s *privep); +static void stm32_cancelrequests(struct stm32_ep_s *privep, int status); /* Interrupt level processing ***********************************************/ @@ -1368,13 +1369,13 @@ static int stm32_rdrequest(struct stm32_usbdev_s *priv, struct stm32_ep_s *prive * Name: stm32_cancelrequests ****************************************************************************/ -static void stm32_cancelrequests(struct stm32_ep_s *privep) +static void stm32_cancelrequests(struct stm32_ep_s *privep, int status) { while (!stm32_rqempty(privep)) { usbtrace(TRACE_COMPLETE(USB_EPNO(privep->ep.eplog)), (stm32_rqpeek(privep))->req.xfrd); - stm32_reqcomplete(privep, -ESHUTDOWN); + stm32_reqcomplete(privep, status); } } @@ -2225,12 +2226,10 @@ static int stm32_lpinterrupt(int irq, void *context) if ((istr & USB_ISTR_RESET) != 0) { - /* Wakeup interrupt received. Clear the WKUP interrupt status. The cause of - * the wakeup is indicated in the FNR register - */ + /* Reset interrupt received. Clear the RESET interrupt status. */ stm32_putreg(~USB_ISTR_RESET, STM32_USB_ISTR); - usbtrace(TRACE_INTDECODE(STM32_TRACEINTID_RESET), stm32_getreg(STM32_USB_FNR)); + usbtrace(TRACE_INTDECODE(STM32_TRACEINTID_RESET), istr); /* Restore our power-up state and exit now because istr is no longer * valid. @@ -2246,10 +2245,12 @@ static int stm32_lpinterrupt(int irq, void *context) if ((istr & USB_ISTR_WKUP & priv->imask) != 0) { - /* Wakeup interrupt received. Clear the WKUP interrupt status. */ + /* Wakeup interrupt received. Clear the WKUP interrupt status. The + * cause of the resume is indicated in the FNR register + */ stm32_putreg(~USB_ISTR_WKUP, STM32_USB_ISTR); - usbtrace(TRACE_INTDECODE(STM32_TRACEINTID_WKUP), 0); + usbtrace(TRACE_INTDECODE(STM32_TRACEINTID_WKUP), stm32_getreg(STM32_USB_FNR)); /* Perform the wakeup action */ @@ -2689,7 +2690,7 @@ static int stm32_epdisable(struct usbdev_ep_s *ep) /* Cancel any ongoing activity */ flags = irqsave(); - stm32_cancelrequests(privep); + stm32_cancelrequests(privep, -ESHUTDOWN); /* Disable TX; disable RX */ @@ -2877,7 +2878,7 @@ static int stm32_epcancel(struct usbdev_ep_s *ep, struct usbdev_req_s *req) priv = privep->dev; flags = irqsave(); - stm32_cancelrequests(privep); + stm32_cancelrequests(privep, -ESHUTDOWN); irqrestore(flags); return OK; } @@ -3226,9 +3227,12 @@ static void stm32_reset(struct stm32_usbdev_s *priv) { struct stm32_ep_s *privep = &priv->eplist[epno]; - /* Cancel any queue requests */ + /* Cancel any queued write requests */ - stm32_cancelrequests(privep); + if (USB_ISEPIN(privep->ep.eplog)) + { + stm32_cancelrequests(privep, -EPIPE); + } /* Reset endpoint status */ diff --git a/drivers/usbdev/usbdev_scsi.c b/drivers/usbdev/usbdev_scsi.c index 700bb64fb2..75c5b50d36 100644 --- a/drivers/usbdev/usbdev_scsi.c +++ b/drivers/usbdev/usbdev_scsi.c @@ -2544,12 +2544,12 @@ void *usbstrg_workerthread(void *arg) usbstrg_resetconfig(priv); } - /* These events require that a new configuration be established */ + /* These events require that a new configuration be established */ - if ((eventset & (USBSTRG_EVENT_CFGCHANGE|USBSTRG_EVENT_IFCHANGE)) != 0) - { - usbstrg_setconfig(priv, priv->thvalue); - } + if ((eventset & (USBSTRG_EVENT_CFGCHANGE|USBSTRG_EVENT_IFCHANGE)) != 0) + { + usbstrg_setconfig(priv, priv->thvalue); + } /* These events required that we send a deferred EP0 setup response */ diff --git a/drivers/usbdev/usbdev_storage.c b/drivers/usbdev/usbdev_storage.c index 43c02c66f4..79b037478f 100644 --- a/drivers/usbdev/usbdev_storage.c +++ b/drivers/usbdev/usbdev_storage.c @@ -1073,7 +1073,7 @@ static void usbstrg_lununinitialize(struct usbstrg_lun_s *lun) * * Description: * Set the device configuration by allocating and configuring endpoints and - * by allocating and queue read and write requests. + * by allocating and queuing read and write requests. * ****************************************************************************/ @@ -1101,7 +1101,7 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config) /* Already configured -- Do nothing */ usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_ALREADYCONFIGURED), 0); - return 0; + return OK; } /* Discard the previous configuration data */ @@ -1113,7 +1113,7 @@ int usbstrg_setconfig(FAR struct usbstrg_dev_s *priv, ubyte config) if (config == USBSTRG_CONFIGIDNONE) { usbtrace(TRACE_CLSERROR(USBSTRG_TRACEERR_CONFIGNONE), 0); - return 0; + return OK; } /* We only accept one configuration */