Skip to content

Commit e432a16

Browse files
committed
mtd: spi-nor: don't drop sfdp data if optional parsers fail
JESD216C states that just the Basic Flash Parameter Table is mandatory. Already defined (or future) additional parameter headers and tables are optional. Don't drop already collected sfdp data in case an optional table parser fails. In case of failing, each optional parser is responsible to roll back to the previously known spi_nor data. Fixes: b038e8e ("mtd: spi-nor: parse SFDP Sector Map Parameter Table") Reported-by: Yogesh Gaur <yogeshnarayan.gaur@nxp.com> Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> Tested-by: Yogesh Gaur <yogeshnarayan.gaur@nxp.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> (cherry picked from commit cd5e6d7) Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
1 parent e397924 commit e432a16

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

drivers/mtd/spi-nor/spi-nor.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,7 +3074,7 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
30743074
if (err)
30753075
goto exit;
30763076

3077-
/* Parse other parameter headers. */
3077+
/* Parse optional parameter tables. */
30783078
for (i = 0; i < header.nph; i++) {
30793079
param_header = &param_headers[i];
30803080

@@ -3087,8 +3087,17 @@ static int spi_nor_parse_sfdp(struct spi_nor *nor,
30873087
break;
30883088
}
30893089

3090-
if (err)
3091-
goto exit;
3090+
if (err) {
3091+
dev_warn(dev, "Failed to parse optional parameter table: %04x\n",
3092+
SFDP_PARAM_HEADER_ID(param_header));
3093+
/*
3094+
* Let's not drop all information we extracted so far
3095+
* if optional table parsers fail. In case of failing,
3096+
* each optional parser is responsible to roll back to
3097+
* the previously known spi_nor data.
3098+
*/
3099+
err = 0;
3100+
}
30923101
}
30933102

30943103
exit:

0 commit comments

Comments
 (0)