Skip to content

Commit

Permalink
w25qxxxjv: fix missing QSPI locking
Browse files Browse the repository at this point in the history
There was a missing QSPI locking for w25qxxxjv_get_die_from_addr
function. We can't have the lock directly in w25qxxxjv_get_die_from_addr
because the function is called from already locked function
w25qxxxjv_erase_sector.

Signed-off-by: Michal Lenc <[email protected]>
  • Loading branch information
michallenc authored and xiaoxiang781216 committed Jan 30, 2025
1 parent f53afd1 commit cde21ae
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/mtd/w25qxxxjv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1409,12 +1409,16 @@ static ssize_t w25qxxxjv_bread(FAR struct mtd_dev_s *dev, off_t startblock,
* read
*/

w25qxxxjv_lock(priv->qspi);

if (priv->numofdies != 0)
{
priv->currentdie = w25qxxxjv_get_die_from_addr(priv, startblock <<
priv->pageshift);
}

w25qxxxjv_unlock(priv->qspi);

#ifdef CONFIG_W25QXXXJV_SECTOR512
nbytes = w25qxxxjv_read(dev, startblock << W25QXXXJV_SECTOR512_SHIFT,
nblocks << W25QXXXJV_SECTOR512_SHIFT, buffer);
Expand Down Expand Up @@ -1447,6 +1451,8 @@ static ssize_t w25qxxxjv_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
finfo("startblock: %08" PRIxOFF " nblocks: %d\n",
startblock, (int)nblocks);

w25qxxxjv_lock(priv->qspi);

if (priv->numofdies != 0)
{
priv->currentdie = w25qxxxjv_get_die_from_addr(priv, startblock <<
Expand All @@ -1455,8 +1461,6 @@ static ssize_t w25qxxxjv_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,

/* Lock the QuadSPI bus and write all of the pages to FLASH */

w25qxxxjv_lock(priv->qspi);

#if defined(CONFIG_W25QXXXJV_SECTOR512)
ret = w25qxxxjv_write_cache(priv, buffer, startblock, nblocks);
if (ret < 0)
Expand Down

0 comments on commit cde21ae

Please sign in to comment.