ST25FL1: Fix error that was overwriting status

This commit is contained in:
Gregory Nutt 2015-11-05 10:32:56 -06:00
parent 3e2e5091cb
commit a314b2ac11
2 changed files with 23 additions and 10 deletions

2
arch

@ -1 +1 @@
Subproject commit 309bd15763dfa0d7e803811216c3b17262255de6
Subproject commit f0cd7a9c410151fb4b8c7737366b501294fc54f2

View File

@ -319,6 +319,7 @@ struct st25fl1_dev_s
uint8_t sectorshift; /* Log2 of sector size */
uint8_t pageshift; /* Log2 of page size */
FAR uint8_t *cmdbuf; /* Allocated command buffer */
FAR uint8_t *readbuf; /* Allocated status read buffer */
#ifdef CONFIG_ST25FL1_SECTOR512
uint8_t flags; /* Buffered sector flags */
@ -518,8 +519,8 @@ static int st25fl1_command_write(FAR struct qspi_dev_s *qspi, uint8_t cmd,
static uint8_t sf25fl1_read_status1(FAR struct st25fl1_dev_s *priv)
{
DEBUGVERIFY(st25fl1_command_read(priv->qspi, ST25FL1_READ_STATUS1,
(FAR void *)&priv->cmdbuf[0], 1));
return priv->cmdbuf[0];
(FAR void *)&priv->readbuf[0], 1));
return priv->readbuf[0];
}
/************************************************************************************
@ -529,8 +530,8 @@ static uint8_t sf25fl1_read_status1(FAR struct st25fl1_dev_s *priv)
static uint8_t sf25fl1_read_status2(FAR struct st25fl1_dev_s *priv)
{
DEBUGVERIFY(st25fl1_command_read(priv->qspi, ST25FL1_READ_STATUS2,
(FAR void *)&priv->cmdbuf[0], 1));
return priv->cmdbuf[0];
(FAR void *)&priv->readbuf[0], 1));
return priv->readbuf[0];
}
/************************************************************************************
@ -540,8 +541,8 @@ static uint8_t sf25fl1_read_status2(FAR struct st25fl1_dev_s *priv)
static uint8_t sf25fl1_read_status3(FAR struct st25fl1_dev_s *priv)
{
DEBUGVERIFY(st25fl1_command_read(priv->qspi, ST25FL1_READ_STATUS3,
(FAR void *)&priv->cmdbuf[0], 1));
return priv->cmdbuf[0];
(FAR void *)&priv->readbuf[0], 1));
return priv->readbuf[0];
}
/************************************************************************************
@ -1450,7 +1451,7 @@ FAR struct mtd_dev_s *st25fl1_initialize(FAR struct qspi_dev_s *qspi)
priv->mtd.ioctl = st25fl1_ioctl;
priv->qspi = qspi;
/* Allocate a tiny buffer to support DMA command data */
/* Allocate a 4-byte buffer to support DMA command data */
priv->cmdbuf = (FAR uint8_t *)QSPI_ALLOC(qspi, 4);
if (priv->cmdbuf == NULL)
@ -1459,6 +1460,15 @@ FAR struct mtd_dev_s *st25fl1_initialize(FAR struct qspi_dev_s *qspi)
goto errout_with_priv;
}
/* Allocate a one-byte buffer to support DMA status read data */
priv->readbuf = (FAR uint8_t *)QSPI_ALLOC(qspi, 1);
if (priv->readbuf == NULL)
{
fdbg("ERROR Failed to allocate read buffer\n");
goto errout_with_cmdbuf;
}
/* Identify the FLASH chip and get its capacity */
ret = st25fl1_readid(priv);
@ -1467,7 +1477,7 @@ FAR struct mtd_dev_s *st25fl1_initialize(FAR struct qspi_dev_s *qspi)
/* Unrecognized! Discard all of that work we just did and return NULL */
fdbg("ERROR Unrecognized QSPI device\n");
goto errout_with_cmdbuf;
goto errout_with_readbuf;
}
/* Enable quad mode */
@ -1493,7 +1503,7 @@ FAR struct mtd_dev_s *st25fl1_initialize(FAR struct qspi_dev_s *qspi)
/* Allocation failed! Discard all of that work we just did and return NULL */
fdbg("ERROR: Sector allocation failed\n");
goto errout_with_cmdbuf;
goto errout_with_readbuf;
}
#endif
}
@ -1509,6 +1519,9 @@ FAR struct mtd_dev_s *st25fl1_initialize(FAR struct qspi_dev_s *qspi)
fvdbg("Return %p\n", priv);
return (FAR struct mtd_dev_s *)priv;
errout_with_readbuf:
QSPI_FREE(qspi, priv->readbuf);
errout_with_cmdbuf:
QSPI_FREE(qspi, priv->cmdbuf);