diff mbox series

[1/5] mtd: spi: Call sst_write in _write ops

Message ID 20200514121145.28737-2-jagan@amarulasolutions.com
State Accepted
Commit 46e4cdff1ee2b07e590b1a91d761f98e26ff3667
Headers show
Series sf: Cleanup | expand

Commit Message

Jagan Teki May 14, 2020, 12:11 p.m. UTC
Currently spi-nor code is assigning _write ops for SST
and other flashes separately.?

Just call the sst_write from generic write ops and return
if SST flash found, this way it avoids the confusion of
multiple write ops assignment during the scan and makes
it more feasible for code readability.

No functionality changes.

Cc: Simon Glass <sjg at chromium.org>
Cc: Vignesh R <vigneshr at ti.com>
Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
---
 drivers/mtd/spi/spi-nor-core.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Jagan Teki May 19, 2020, 7:15 p.m. UTC | #1
On Thu, May 14, 2020 at 5:41 PM Jagan Teki <jagan at amarulasolutions.com> wrote:
>
> Currently spi-nor code is assigning _write ops for SST
> and other flashes separately.
>
> Just call the sst_write from generic write ops and return
> if SST flash found, this way it avoids the confusion of
> multiple write ops assignment during the scan and makes
> it more feasible for code readability.
>
> No functionality changes.
>
> Cc: Simon Glass <sjg at chromium.org>
> Cc: Vignesh R <vigneshr at ti.com>
> Signed-off-by: Jagan Teki <jagan at amarulasolutions.com>
> ---

Applied to u-boot-spi/master
diff mbox series

Patch

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 3d4361493e..984cece0b0 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -1233,6 +1233,12 @@  static int spi_nor_write(struct mtd_info *mtd, loff_t to, size_t len,
 	size_t page_offset, page_remain, i;
 	ssize_t ret;
 
+#ifdef CONFIG_SPI_FLASH_SST
+	/* sst nor chips use AAI word program */
+	if (nor->info->flags & SST_WRITE)
+		return sst_write(mtd, to, len, retlen, buf);
+#endif
+
 	dev_dbg(nor->dev, "to 0x%08x, len %zd\n", (u32)to, len);
 
 	if (!len)
@@ -2528,6 +2534,7 @@  int spi_nor_scan(struct spi_nor *nor)
 	mtd->size = params.size;
 	mtd->_erase = spi_nor_erase;
 	mtd->_read = spi_nor_read;
+	mtd->_write = spi_nor_write;
 
 #if defined(CONFIG_SPI_FLASH_STMICRO) || defined(CONFIG_SPI_FLASH_SST)
 	/* NOR protection support for STmicro/Micron chips and similar */
@@ -2551,13 +2558,7 @@  int spi_nor_scan(struct spi_nor *nor)
 		nor->flash_unlock = sst26_unlock;
 		nor->flash_is_locked = sst26_is_locked;
 	}
-
-	/* sst nor chips use AAI word program */
-	if (info->flags & SST_WRITE)
-		mtd->_write = sst_write;
-	else
 #endif
-		mtd->_write = spi_nor_write;
 
 	if (info->flags & USE_FSR)
 		nor->flags |= SNOR_F_USE_FSR;