USB host: Fix an attempt to take a semaphore from an interrupt handler

This commit is contained in:
Gregory Nutt 2015-04-26 10:05:15 -06:00
parent 397f31f061
commit d88d10830e
3 changed files with 21 additions and 37 deletions

View File

@ -800,11 +800,12 @@ static void usbhost_destroy(FAR void *arg)
DRVR_DISCONNECT(hport->drvr);
/* And free the class instance. Hmmm.. this may execute on the worker
* thread and the work structure is part of what is getting freed. That
* should be okay because once the work contained is removed from the
* queue, it should not longer be accessed by the worker thread.
*/
/* Free the function address assigned to this device */
usbhost_devaddr_destroy(hport, hport->funcaddr);
hport->funcaddr = 0;
/* And free the class instance. */
usbhost_freeclass(priv);
}
@ -1981,10 +1982,8 @@ static int usbhost_connect(FAR struct usbhost_class_s *usbclass,
static int usbhost_disconnected(struct usbhost_class_s *usbclass)
{
FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass;
FAR struct usbhost_hubport_s *hport;
DEBUGASSERT(priv != NULL && priv->usbclass.hport != NULL);
hport = priv->usbclass.hport;
DEBUGASSERT(priv != NULL);
/* Set an indication to any users of the keyboard device that the device
* is no longer available.
@ -2033,10 +2032,6 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass)
(void)work_queue(HPWORK, &priv->work, usbhost_destroy, priv, 0);
}
/* Free the function address assigned to this device */
usbhost_devaddr_destroy(hport, hport->funcaddr);
hport->funcaddr = 0;
return OK;
}

View File

@ -656,11 +656,12 @@ static void usbhost_destroy(FAR void *arg)
DRVR_DISCONNECT(hport->drvr);
/* And free the class instance. Hmmm.. this may execute on the worker
* thread and the work structure is part of what is getting freed. That
* should be okay because once the work contained is removed from the
* queue, it should not longer be accessed by the worker thread.
*/
/* Free the function address assigned to this device */
usbhost_devaddr_destroy(hport, hport->funcaddr);
hport->funcaddr = 0;
/* And free the class instance. */
usbhost_freeclass(priv);
}
@ -2047,11 +2048,9 @@ static int usbhost_connect(FAR struct usbhost_class_s *usbclass,
static int usbhost_disconnected(struct usbhost_class_s *usbclass)
{
FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass;
FAR struct usbhost_hubport_s *hport;
int i;
DEBUGASSERT(priv != NULL && priv->usbclass.hport != NULL);
hport = priv->usbclass.hport;
DEBUGASSERT(priv != NULL);
/* Set an indication to any users of the mouse device that the device
* is no longer available.
@ -2099,10 +2098,6 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass)
(void)work_queue(HPWORK, &priv->work, usbhost_destroy, priv, 0);
}
/* Free the function address assigned to this device */
usbhost_devaddr_destroy(hport, hport->funcaddr);
hport->funcaddr = 0;
return OK;
}

View File

@ -954,11 +954,12 @@ static void usbhost_destroy(FAR void *arg)
DRVR_DISCONNECT(hport->drvr);
/* And free the class instance. Hmmm.. this may execute on the worker
* thread and the work structure is part of what is getting freed. That
* should be okay because once the work contained is removed from the
* queue, it should not longer be accessed by the worker thread.
*/
/* Free the function address assigned to this device */
usbhost_devaddr_destroy(hport, hport->funcaddr);
hport->funcaddr = 0;
/* And free the class instance. */
usbhost_freeclass(priv);
}
@ -1810,11 +1811,9 @@ static int usbhost_connect(FAR struct usbhost_class_s *usbclass,
static int usbhost_disconnected(struct usbhost_class_s *usbclass)
{
FAR struct usbhost_state_s *priv = (FAR struct usbhost_state_s *)usbclass;
FAR struct usbhost_hubport_s *hport;
irqstate_t flags;
DEBUGASSERT(priv != NULL && priv->usbclass.hport != NULL);
hport = priv->usbclass.hport;
DEBUGASSERT(priv != NULL);
/* Set an indication to any users of the mass storage device that the device
* is no longer available.
@ -1854,11 +1853,6 @@ static int usbhost_disconnected(struct usbhost_class_s *usbclass)
}
irqrestore(flags);
/* Free the function address assigned to this device */
usbhost_devaddr_destroy(hport, hport->funcaddr);
hport->funcaddr = 0;
return OK;
}