mtd: spi: Call sst_write in _write ops
[oweals/u-boot.git] / drivers / mtd / spi / spi-nor-core.c
index 310d477f004107a1f73607b273806b7364cb1ea3..1e3f51d2acbff452c339a95dda6f4edc69d0483f 100644 (file)
@@ -1235,6 +1235,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)
@@ -2530,6 +2536,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 */
@@ -2553,13 +2560,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;