SAM3,4,A5: Fix some masked status checks that can generate false error reports

This commit is contained in:
Gregory Nutt 2013-08-06 12:36:56 -06:00
parent dfe42d0254
commit 03f24c7a1d
2 changed files with 16 additions and 10 deletions

View File

@ -1687,6 +1687,7 @@ static int sam_waitresponse(FAR struct sdio_dev_s *dev, uint32_t cmd)
{
struct sam_dev_s *priv = (struct sam_dev_s*)dev;
uint32_t sr;
uint32_t pending;
int32_t timeout;
switch (cmd & MMCSD_RESPONSE_MASK)
@ -1719,21 +1720,23 @@ static int sam_waitresponse(FAR struct sdio_dev_s *dev, uint32_t cmd)
/* Did a Command-Response sequence termination evernt occur? */
sr = getreg32(SAM_HSMCI_SR);
if ((sr & priv->cmdrmask) != 0)
pending = sr & priv->cmdrmask;
if (pending != 0)
{
sam_cmdsample2(SAMPLENDX_AT_WAKEUP, sr);
sam_cmddump();
/* Yes.. Did the Command-Response sequence end with an error? */
if ((sr & HSMCI_RESPONSE_ERRORS) != 0)
if ((pending & HSMCI_RESPONSE_ERRORS) != 0)
{
/* Yes.. Was the error some kind of timeout? */
fdbg("ERROR: cmd: %08x events: %08x SR: %08x\n",
cmd, priv->cmdrmask, sr);
if ((sr & HSMCI_RESPONSE_TIMEOUT_ERRORS) != 0)
if ((pending & HSMCI_RESPONSE_TIMEOUT_ERRORS) != 0)
{
/* Yes.. return a timeout error */

View File

@ -1984,6 +1984,7 @@ static int sam_waitresponse(FAR struct sdio_dev_s *dev, uint32_t cmd)
{
struct sam_dev_s *priv = (struct sam_dev_s*)dev;
uint32_t sr;
uint32_t pending;
int32_t timeout;
switch (cmd & MMCSD_RESPONSE_MASK)
@ -2016,21 +2017,23 @@ static int sam_waitresponse(FAR struct sdio_dev_s *dev, uint32_t cmd)
/* Did a Command-Response sequence termination evernt occur? */
sr = sam_getreg(priv, SAM_HSMCI_SR_OFFSET);
if ((sr & priv->cmdrmask) != 0)
pending = sr & priv->cmdrmask;
if (pending != 0)
{
sam_cmdsample2(priv, SAMPLENDX_AT_WAKEUP, sr);
sam_cmddump(priv);
/* Yes.. Did the Command-Response sequence end with an error? */
if ((sr & HSMCI_RESPONSE_ERRORS) != 0)
if ((pending & HSMCI_RESPONSE_ERRORS) != 0)
{
/* Yes.. Was the error some kind of timeout? */
fdbg("ERROR: cmd: %08x events: %08x SR: %08x\n",
cmd, priv->cmdrmask, sr);
if ((sr & HSMCI_RESPONSE_TIMEOUT_ERRORS) != 0)
if ((pending & HSMCI_RESPONSE_TIMEOUT_ERRORS) != 0)
{
/* Yes.. return a timeout error */