summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-04-25 16:47:28 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-04-25 16:47:28 +0000
commitffcaa123f477ac9062398c06b68950203f0c899a (patch)
tree5ae0d3a4edccd428088dcf117a5241387c6d6f21
parent798d0d0debae5b8dc0f40844adf18ce14906cfd7 (diff)
downloadnuttx-ffcaa123f477ac9062398c06b68950203f0c899a.tar.gz
nuttx-ffcaa123f477ac9062398c06b68950203f0c899a.tar.bz2
nuttx-ffcaa123f477ac9062398c06b68950203f0c899a.zip
Fix infinite loop in CDC/ACM driver
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4655 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--nuttx/ChangeLog5
-rwxr-xr-xnuttx/arch/arm/src/stm32/stm32_otgfsdev.c15
-rw-r--r--nuttx/drivers/usbdev/cdcacm.c18
3 files changed, 30 insertions, 8 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 29ce31c1a..919ad1778 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -2681,4 +2681,9 @@
PIC32MX7 Multimedia Board (MMB).
* net/recvfrom.c: Fix a compilation problem. Some UDP logic was conditioned
on TCP, not UDP.
+ * drivers/usbdev/cdcacm.c: Fix an infinite loop that occurs when the serial
+ device is unregisters.
+ * arch/arm/src/stm32/stm32_otgfs.c: The driver needs to reset the software (in
+ order to flush the requests) and to disable the software connection when the
+ device is unregistered.
diff --git a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
index 6604a004b..e36f4e33b 100755
--- a/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
+++ b/nuttx/arch/arm/src/stm32/stm32_otgfsdev.c
@@ -1870,6 +1870,7 @@ static void stm32_usbreset(struct stm32_usbdev_s *priv)
privep->stalled = false;
}
+
stm32_putreg(0xffffffff, STM32_OTGFS_DAINT);
/* Mask all device endpoint interrupts except EP0 */
@@ -5283,6 +5284,7 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
*/
FAR struct stm32_usbdev_s *priv = &g_otgfsdev;
+ irqstate_t flags;
usbtrace(TRACE_DEVUNREGISTER, 0);
@@ -5294,6 +5296,13 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
}
#endif
+ /* Reset the hardware and cancel all requests. All requests must be
+ * canceled while the class driver is still bound.
+ */
+
+ flags = irqsave();
+ stm32_usbreset(priv);
+
/* Unbind the class driver */
CLASS_UNBIND(driver, &priv->usbdev);
@@ -5302,9 +5311,15 @@ int usbdev_unregister(struct usbdevclass_driver_s *driver)
up_disable_irq(STM32_IRQ_OTGFS);
+ /* Disconnect device */
+
+ stm32_pullup(&priv->usbdev, false);
+
/* Unhook the driver */
priv->driver = NULL;
+ irqrestore(flags);
+
return OK;
}
diff --git a/nuttx/drivers/usbdev/cdcacm.c b/nuttx/drivers/usbdev/cdcacm.c
index 2065b5433..24903b504 100644
--- a/nuttx/drivers/usbdev/cdcacm.c
+++ b/nuttx/drivers/usbdev/cdcacm.c
@@ -2182,14 +2182,16 @@ void cdcacm_uninitialize(FAR void *handle)
usbtrace(TRACE_CLSERROR(USBSER_TRACEERR_UARTUNREGISTER), (uint16_t)-ret);
}
- /* Unbind the class (if still bound) */
-
- if (priv->usbdev)
- {
- cdcacm_unbind(&drvr->drvr, priv->usbdev);
- }
-
- /* Unregister the driver (unless we are a part of a composite device) */
+ /* Unregister the driver (unless we are a part of a composite device). The
+ * device unregister logic will (1) return all of the requests to us then
+ * (2) all the unbind method.
+ *
+ * The same thing will happen in the composite case except that: (1) the
+ * composite driver will call usbdev_unregister() which will (2) return the
+ * requests for all members of the composite, and (3) call the unbind
+ * method in the composite device which will (4) call the unbind method
+ * for this device.
+ */
#ifndef CONFIG_CDCACM_COMPOSITE
usbdev_unregister(&drvr->drvr);