Merged in antmerlino/nuttx/mmcsd-bugfix (pull request #893)
drivers/mmcsd: Fixes bug where thread gets deadlocked due to recursive call and addresses comment regarding events. When initializing the MMCSD, if we are being told there is a card, but we fail to initialize it, we should not re-register for an insertion event as this will immediately cause us to call in again. Instead, we should register for a removal event and wait for the card to be removed and re-inserted. Approved-by: Gregory Nutt <gnutt@nuttx.org>
This commit is contained in:
parent
eab1b11d7d
commit
5cd2a1ae68
|
@ -3094,9 +3094,6 @@ static int mmcsd_probe(FAR struct mmcsd_state_s *priv)
|
|||
if (ret != OK)
|
||||
{
|
||||
ferr("ERROR: Failed to initialize card: %d\n", ret);
|
||||
#ifdef CONFIG_MMCSD_HAVE_CARDDETECT
|
||||
SDIO_CALLBACKENABLE(priv->dev, SDIOMEDIA_INSERTED);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3130,22 +3127,25 @@ static int mmcsd_probe(FAR struct mmcsd_state_s *priv)
|
|||
|
||||
finfo("Capacity: %lu Kbytes\n", (unsigned long)(priv->capacity / 1024));
|
||||
priv->mediachanged = true;
|
||||
|
||||
#ifdef CONFIG_MMCSD_HAVE_CARDDETECT
|
||||
/* Set up to receive asynchronous, media removal events */
|
||||
|
||||
SDIO_CALLBACKENABLE(priv->dev, SDIOMEDIA_EJECTED);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* REVISIT: There is a problem here. If mmcsd_initialize() returns a
|
||||
* failure, then no events are initialized.
|
||||
*/
|
||||
}
|
||||
|
||||
/* In any event, we have probed this card */
|
||||
|
||||
priv->probed = true;
|
||||
|
||||
/* Regardless of whether or not a card was successfully initialized, there
|
||||
* is appartently a card inserted. If it wasn't successfully initialized,
|
||||
* there's nothing we can do about it now. Perhaps it's a bad card? The best
|
||||
* we can do is wait for the card to be ejected and re-inserted. Then we
|
||||
* can try to initialize again.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_MMCSD_HAVE_CARDDETECT
|
||||
/* Set up to receive asynchronous, media removal events */
|
||||
|
||||
SDIO_CALLBACKENABLE(priv->dev, SDIOMEDIA_EJECTED);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue