mtd: spi-nor: core: Skip setting erase types when SPI_NOR_NO_ERASE is set
Subsystems (3)
PATCH v2 1/1 mtd: spi-nor: core: Skip setting erase types when SPI_NOR_NO_ERASE is set
Even if SPI_NOR_NO_ERASE was specified at flash declaration, the erase type of size nor->info->sector_size was incorrectly set as supported. Don't set erase types when SPI_NOR_NO_ERASE is set.
---
v2:
- add comment, update commit message, split change in individual commit
- add fixes tag and cc to stable.
drivers/mtd/spi-nor/core.c | 4 ++++ 1 file changed, 4 insertions(+)
drivers/mtd/spi-nor/core.c +4 -0
@@ -2392,6 +2392,10 @@ static void spi_nor_no_sfdp_init_params(struct spi_nor *nor) SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR); } +/* Skip setting erase types when SPI_NOR_NO_ERASE is set. */ +if (nor->info->flags &SPI_NOR_NO_ERASE ) +return ; +/* * Sector Erase settings. Sort Erase Types in ascending order, with the * smallest erase size starting at BIT(0).
Signature · 1 line
2.25.1
Quoted 3 lines · Tudor Ambarus
Even if
SPI_NOR_NO_ERASEwas specified at flash declaration, the erase type of sizenor->info->sector_sizewas incorrectly set as supported. Don't set erase types whenSPI_NOR_NO_ERASEis set.
Does this have any practical implications? Since we set MTD_NO_ERASE, erase should never be called for this flash anyway, right?
Quoted 30 lines
Fixes b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")Signed-off-by Tudor Ambarus <[email protected]>---
v2:
- add comment, update commit message, split change in individual commit
- add fixes tag and cc to stable.drivers/mtd/spi-nor/core.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mtd/spi-nor/core.c +4
-0@@ -2392,6 +2392,10 @@ static void spi_nor_no_sfdp_init_params(struct spi_nor *nor) SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR); } +/* Skip setting erase types when SPI_NOR_NO_ERASE is set. */ +if (nor->info->flags &SPI_NOR_NO_ERASE ) +return ; +/* * Sector Erase settings. Sort Erase Types in ascending order, with the * smallest erase size starting at BIT(0). Signature · 1 line
2.25.1
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.
Quoted 28 lines · Pratyush Yadav
Quoted 3 lines · Tudor Ambarus
Even if
SPI_NOR_NO_ERASEwas specified at flash declaration, the erase type of sizenor->info->sector_sizewas incorrectly set as supported. Don't set erase types whenSPI_NOR_NO_ERASEis set.Does this have any practical implications? Since we set
MTD_NO_ERASE, erase should never be called for this flash anyway, right?Quoted 20 lines
Fixes b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")Signed-off-by Tudor Ambarus <[email protected]>---
v2:
- add comment, update commit message, split change in individual commit
- add fixes tag and cc to stable.drivers/mtd/spi-nor/core.c | 4 ++++ 1 file changed, 4 insertions(+)drivers/mtd/spi-nor/core.c +0
-0@@ -2392,6 +2392,10 @@ static void spi_nor_no_sfdp_init_params(struct spi_nor *nor) SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR); }
Quoted 3 lines
drivers/mtd/spi-nor/core.c static void spi_nor_no_sfdp_init_params(struct spi_nor *nor) · line 2397
Quoted 3 lines
drivers/mtd/spi-nor/core.c +3
-0+/* Skip setting erase types when SPI_NOR_NO_ERASE is set. */ +if (nor->info->flags &SPI_NOR_NO_ERASE ) +return ;
Can you instead do
if (!(nor->info->flags & SPI_NOR_NO_ERASE)) {
...
}This way when someone adds code to the bottom of this function that sets something other than erase types it will execute for flashes with SPI_NOR_NO_ERASE as well.
Quoted 16 lines
Quoted 7 lines
drivers/mtd/spi-nor/core.c +1
-0+/* * Sector Erase settings. Sort Erase Types in ascending order, with the * smallest erase size starting at BIT(0). Signature · 1 line
2.25.1Signature · 7 lines
Regards, Pratyush Yadav Texas Instruments Inc. ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Signature · 3 lines
Regards, Pratyush Yadav Texas Instruments Inc.