[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b8eb5a09b0a716093299ad4e6a3f727e@walle.cc>
Date: Tue, 01 Mar 2022 23:35:38 +0100
From: Michael Walle <michael@...le.cc>
To: Tudor Ambarus <tudor.ambarus@...rochip.com>
Cc: p.yadav@...com, miquel.raynal@...tlin.com, richard@....at,
vigneshr@...com, linux-mtd@...ts.infradead.org,
linux-kernel@...r.kernel.org, nicolas.ferre@...rochip.com,
stable@...r.kernel.org
Subject: Re: [PATCH] mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE is
set
Am 2022-02-28 17:33, schrieb Tudor Ambarus:
> Even if SPI_NOR_NO_ERASE was set, one could still send erase opcodes
> to the flash. It is not recommended to send unsupported opcodes to
> flashes. Fix the logic and do not set mtd->_erase when SPI_NOR_NO_ERASE
> is specified. With this users will not be able to issue erase opcodes
> to
> flashes and instead they will recive an -ENOTSUPP error.
But why is there an erase opcode and erase size set in the
first place? spi_nor_select_erase() should probably return
early if SPI_NOR_NO_ERASE is set. Not setting the erasesize
would also return -ENOTSUPP. I prefer this one for a fixes
patch, though. But spi_nor_select_erase() should also be
fixed.
Reviewed-by: Michael Walle <michael@...le.cc>
>
> Cc: stable@...r.kernel.org
> Fixes: b199489d37b2 ("mtd: spi-nor: add the framework for SPI NOR")
> Signed-off-by: Tudor Ambarus <tudor.ambarus@...rochip.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 86a536c97c18..cd2d094ef837 100644
> --- a/drivers/mtd/spi-nor/core.c
> +++ b/drivers/mtd/spi-nor/core.c
> @@ -2969,10 +2969,11 @@ static void spi_nor_set_mtd_info(struct spi_nor
> *nor)
> mtd->flags = MTD_CAP_NORFLASH;
> if (nor->info->flags & SPI_NOR_NO_ERASE)
> mtd->flags |= MTD_NO_ERASE;
> + else
> + mtd->_erase = spi_nor_erase;
> mtd->writesize = nor->params->writesize;
> mtd->writebufsize = nor->params->page_size;
> mtd->size = nor->params->size;
> - mtd->_erase = spi_nor_erase;
> mtd->_read = spi_nor_read;
> /* Might be already set by some SST flashes. */
> if (!mtd->_write)
Powered by blists - more mailing lists