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

Tudor Ambarus tudor.ambarus at linaro.org
Tue May 23 02:04:12 PDT 2023


Thanks, Mika,

Miquel already queued a similar fix:
https://lore.kernel.org/linux-mtd/20230522155835.46756-1-miquel.raynal@bootlin.com/T/#m2d00f6d6bfb6298a6e8d81a4795d69db1e3c9505
cheers,
ta
On 5/23/23 08:39, Mika Westerberg wrote:
> 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,



More information about the linux-mtd mailing list