[PATCH v4 2/6] mtd: spi-nor: core: Handle ID collisions between SFDP & non-SFDP flashes
Michael Walle
michael at walle.cc
Tue Mar 1 13:52:45 PST 2022
Am 2022-02-28 14:45, schrieb Tudor Ambarus:
> A typical differentiator between flashes whose ID collide is whether
> they
> support SFDP or not. For such a collision there will be a single
> flash_info entry where the developer should specify:
> 1/ PARSE_SFDP - so that the flash that supports SFDP to initialize its
> parameters by parsing the SFDP tables
> 2/ any of the no_sfdp_flags less SPI_NOR_SKIP_SFDP, to initialize the
> flash parameters via the static no_sfdp_flags for the flash that
> doesn't support SFDP.
> Use the logic the above to handle ID collisions between SFDP & non-SFDP
> flashes.
>
> Signed-off-by: Tudor Ambarus <tudor.ambarus at microchip.com>
> ---
> drivers/mtd/spi-nor/core.c | 13 +++++++++++--
> 1 file changed, 11 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index fbf3278ba29a..aef00151c116 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2639,8 +2639,17 @@ static int spi_nor_init_params(struct spi_nor
> *nor)
> if (nor->info->parse_sfdp) {
> ret = spi_nor_parse_sfdp(nor);
Can we return -ENOENT here if sfdp isn't supported, so we
can differentiate between "no sfdp present" and other errors?
> if (ret) {
> - dev_err(nor->dev, "BFPT parsing failed. Please consider using
> SPI_NOR_SKIP_SFDP when declaring the flash\n");
> - return ret;
> + /*
> + * Handle ID collisions between flashes that support
> + * SFDP and flashes that don't. Initialize parameters
> + * for the flash that doesn't support SFDP.
> + */
> + if (nor->info->no_sfdp_flags & ~SPI_NOR_SKIP_SFDP) {
Shouldn't this be
if (!(nor->info->no_sfdp_flags & SPI_NOR_SKIP_SFDP))
> + spi_nor_no_sfdp_init_params(nor);
> + } else {
> + dev_err(nor->dev, "BFPT parsing failed. Please consider using
> SPI_NOR_SKIP_SFDP when declaring the flash\n");
> + return ret;
> + }
> }
> } else if (nor->info->no_sfdp_flags & SPI_NOR_SKIP_SFDP) {
> spi_nor_no_sfdp_init_params(nor);
-michael
More information about the linux-mtd
mailing list