[PATCH 1/2] mtd: spi-nor: core: Allow manufacturer fixups to set nor->mtd.flags

Tudor Ambarus tudor.ambarus at linaro.org
Fri Mar 17 02:25:41 PDT 2023



On 3/15/23 06:34, tkuw584924 at gmail.com wrote:
> From: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
> 
> Infineon SEMPER Flash family has on-die ECC and multiple programming on
> the same 16-byte ECC data unit is not allowed to preserve ECC.
> 
> In JFFS2, ECC'd NOR Flash is supported when CONFIG_JFFS2_FS_WRITEBUFFER
> is set and MTD_BIT_WRITEABLE is not set in mtd.flag.
> 
> In spi-nor/core, the mtd.flags is set to MTD_CAP_NORFLASH that defined as
> (MTD_WRITEABLE | MTD_BIT_WRITEABLE).
> 
> The mtd.flags should be set to MTD_CAP_NORFLASH in spi-nor/core when it
> is not yet set, to allow manufacturer fixups set it.
> 
> Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano at infineon.com>
> ---
>  drivers/mtd/spi-nor/core.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c
> index 0a78045ca1d9..5be9392b65c1 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2976,7 +2976,8 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor)
>  	if (!mtd->name)
>  		mtd->name = dev_name(dev);
>  	mtd->type = MTD_NORFLASH;
> -	mtd->flags = MTD_CAP_NORFLASH;
> +	if (!mtd->flags)
> +		mtd->flags = MTD_CAP_NORFLASH;

No, I don't want manufacturer drivers to update mtd fields on their own.
Instead, introduce a SNOR_F flag, set it in the manufacturer driver and
then update the mtd->flags here based on the SNOR_F flag.

>  	if (nor->info->flags & SPI_NOR_NO_ERASE)
>  		mtd->flags |= MTD_NO_ERASE;
>  	else



More information about the linux-mtd mailing list