[PATCH] mtd: spi-nor: Initialize n_banks for spi_nor_generic_flash

Mika Westerberg mika.westerberg at linux.intel.com
Tue May 23 00:39:36 PDT 2023


If the flash chip in question is using spi_nor_generic_flash for
flash_info this results a division by zero during spi_nor_scan() because
its n_banks is 0.

Fix this by initializing n_banks for spi_nor_generic_flash to 1.

Fixes: 9d6c5d64f028 ("mtd: spi-nor: Introduce the concept of bank")
Cc: stable at vger.kernel.org
Signed-off-by: Mika Westerberg <mika.westerberg at linux.intel.com>
---
 drivers/mtd/spi-nor/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index 0bb0ad14a2fc..94fc4f6d0844 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -2024,6 +2024,7 @@ static const struct flash_info spi_nor_generic_flash = {
 	 */
 	.page_size = 256,
 	.parse_sfdp = true,
+	.n_banks = 1,
 };
 
 static const struct flash_info *spi_nor_match_id(struct spi_nor *nor,
-- 
2.39.2




More information about the linux-mtd mailing list