From 13d823f30710e6fabd3d6429a03bc37e1086c9e7 Mon Sep 17 00:00:00 2001 From: Sebastien Lorquet Date: Mon, 20 Mar 2023 12:33:31 +0100 Subject: [PATCH] spi_xx25xx: Repair the spi bus locking mechanism when waiting for write completion --- drivers/eeprom/spi_xx25xx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/eeprom/spi_xx25xx.c b/drivers/eeprom/spi_xx25xx.c index f5b94ba430..39f446eab8 100644 --- a/drivers/eeprom/spi_xx25xx.c +++ b/drivers/eeprom/spi_xx25xx.c @@ -377,6 +377,7 @@ static void ee25xx_waitwritecomplete(struct ee25xx_dev_s *priv) { /* Select this FLASH part */ + ee25xx_lock(priv->spi); SPI_SELECT(priv->spi, SPIDEV_EEPROM(0), true); /* Send "Read Status Register (RDSR)" command */ @@ -392,6 +393,7 @@ static void ee25xx_waitwritecomplete(struct ee25xx_dev_s *priv) /* Deselect the FLASH */ SPI_SELECT(priv->spi, SPIDEV_EEPROM(0), false); + ee25xx_unlock(priv->spi); /* Given that writing could take up to a few milliseconds, * the following short delay in the "busy" case will allow @@ -400,9 +402,7 @@ static void ee25xx_waitwritecomplete(struct ee25xx_dev_s *priv) if ((status & EE25XX_SR_WIP) != 0) { - ee25xx_unlock(priv->spi); nxsig_usleep(1000); - ee25xx_lock(priv->spi); } } while ((status & EE25XX_SR_WIP) != 0);