[PATCH v5 02/28] mtd: spi-nor: Complete error rollback on sfdp parsing failure

Miquel Raynal <[email protected]>
Newsgroups gmane.linux.kernel,gmane.linux.drivers.mtd
Message-ID <20260805-winbond-v7-1-spi-nor-jv-cleanup-v5-2-87238e577794@bootlin.com>
Make sure to rollback all changes induced by SFDP parsing in case of
failure, which means also resetting nor->flags and nor->cmd_ext_type.

Signed-off-by: Miquel Raynal <[email protected]>
---
 drivers/mtd/spi-nor/core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
index ccf4396cdcd0..c39c6833c9a4 100644
--- a/drivers/mtd/spi-nor/core.c
+++ b/drivers/mtd/spi-nor/core.c
@@ -3063,12 +3063,17 @@ static int spi_nor_late_init_params(struct spi_nor *nor)
 static void spi_nor_sfdp_init_params_deprecated(struct spi_nor *nor)
 {
 	struct spi_nor_flash_parameter sfdp_params;
+	enum spi_nor_cmd_ext cmd_ext_type;
+	u32 flags;
 
 	memcpy(&sfdp_params, nor->params, sizeof(sfdp_params));
+	cmd_ext_type = nor->cmd_ext_type;
+	flags = nor->flags;
 
 	if (spi_nor_parse_sfdp(nor)) {
 		memcpy(nor->params, &sfdp_params, sizeof(*nor->params));
-		nor->flags &= ~SNOR_F_4B_OPCODES;
+		nor->cmd_ext_type = cmd_ext_type;
+		nor->flags = flags;
 	}
 }
 

-- 
2.54.0
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.