From: Michael Walle Date: Wed, 10 Aug 2022 22:06:52 +0000 (+0200) Subject: mtd: spi-nor: fix select_uniform_erase to skip 0 erase size X-Git-Tag: v6.2-rc1~123^2^2~9 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=39eece67a3cf027aa5b39d7da5feadc4711504e6;p=thirdparty%2Flinux.git mtd: spi-nor: fix select_uniform_erase to skip 0 erase size 4bait will set the erase size to 0 if there is no corresponding opcode for the 4byte erase. Fix spi_nor_select_uniform_erase to skip the 0 erase size to avoid mtd device registration failure cases. Reported-by: Jae Hyun Yoo Signed-off-by: Michael Walle Signed-off-by: Tudor Ambarus Link: https://lore.kernel.org/r/20220810220654.1297699-6-michael@walle.cc --- diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index 1358f3c45d164..2bdc5b50d8da1 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2120,6 +2120,10 @@ spi_nor_select_uniform_erase(struct spi_nor_erase_map *map, tested_erase = &map->erase_type[i]; + /* Skip masked erase types. */ + if (!tested_erase->size) + continue; + /* * If the current erase size is the one, stop here: * we have found the right uniform Sector Erase command.