From: Tudor Ambarus <tudor.ambarus@microchip.com> To: <Alexander.Stein@tq-group.com>, <michael@walle.cc>, <p.yadav@ti.com>, <vigneshr@ti.com> Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>, "Tudor Ambarus" <tudor.ambarus@microchip.com> Subject: [PATCH 2/2] mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE is set Date: Sat, 6 Nov 2021 09:56:16 +0200 [thread overview] Message-ID: <20211106075616.95401-3-tudor.ambarus@microchip.com> (raw) In-Reply-To: <20211106075616.95401-1-tudor.ambarus@microchip.com> SPI_NOR_NO_ERASE is used either by F-RAMs, or MRAMs, or EEPROMs, neither of which supports SFDP, so once SPI_NOR_NO_ERASE is set, SFDP can not undo it. These type of flashes should be moved out of the SPI NOR core anyway, so don't complicate things and just skip the erase logic when SPI_NOR_NO_ERASE is set. Normally SPI NOR core should operate just on SNOR_F flags, but since SPI_NOR_NO_ERASE should be removed, don't bother with extra code. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> --- drivers/mtd/spi-nor/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index a1b5d5432f41..52c82d943499 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2680,6 +2680,9 @@ static void spi_nor_skip_sfdp_init_params(struct spi_nor *nor) SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR); } + if (info_flags & SPI_NOR_NO_ERASE) + return; + /* * Sector Erase settings. Sort Erase Types in ascending order, with the * smallest erase size starting at BIT(0). @@ -3195,12 +3198,13 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor) mtd->name = dev_name(dev); mtd->type = MTD_NORFLASH; mtd->flags = MTD_CAP_NORFLASH; - if (nor->info->flags & SPI_NOR_NO_ERASE) + if (nor->info->flags & SPI_NOR_NO_ERASE) { + mtd->_erase = spi_nor_erase; mtd->flags |= MTD_NO_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) -- 2.25.1
WARNING: multiple messages have this Message-ID (diff)
From: Tudor Ambarus <tudor.ambarus@microchip.com> To: <Alexander.Stein@tq-group.com>, <michael@walle.cc>, <p.yadav@ti.com>, <vigneshr@ti.com> Cc: <linux-mtd@lists.infradead.org>, <linux-kernel@vger.kernel.org>, "Tudor Ambarus" <tudor.ambarus@microchip.com> Subject: [PATCH 2/2] mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE is set Date: Sat, 6 Nov 2021 09:56:16 +0200 [thread overview] Message-ID: <20211106075616.95401-3-tudor.ambarus@microchip.com> (raw) In-Reply-To: <20211106075616.95401-1-tudor.ambarus@microchip.com> SPI_NOR_NO_ERASE is used either by F-RAMs, or MRAMs, or EEPROMs, neither of which supports SFDP, so once SPI_NOR_NO_ERASE is set, SFDP can not undo it. These type of flashes should be moved out of the SPI NOR core anyway, so don't complicate things and just skip the erase logic when SPI_NOR_NO_ERASE is set. Normally SPI NOR core should operate just on SNOR_F flags, but since SPI_NOR_NO_ERASE should be removed, don't bother with extra code. Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com> --- drivers/mtd/spi-nor/core.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c index a1b5d5432f41..52c82d943499 100644 --- a/drivers/mtd/spi-nor/core.c +++ b/drivers/mtd/spi-nor/core.c @@ -2680,6 +2680,9 @@ static void spi_nor_skip_sfdp_init_params(struct spi_nor *nor) SPINOR_OP_PP, SNOR_PROTO_8_8_8_DTR); } + if (info_flags & SPI_NOR_NO_ERASE) + return; + /* * Sector Erase settings. Sort Erase Types in ascending order, with the * smallest erase size starting at BIT(0). @@ -3195,12 +3198,13 @@ static void spi_nor_set_mtd_info(struct spi_nor *nor) mtd->name = dev_name(dev); mtd->type = MTD_NORFLASH; mtd->flags = MTD_CAP_NORFLASH; - if (nor->info->flags & SPI_NOR_NO_ERASE) + if (nor->info->flags & SPI_NOR_NO_ERASE) { + mtd->_erase = spi_nor_erase; mtd->flags |= MTD_NO_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) -- 2.25.1 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2021-11-06 7:56 UTC|newest] Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-06 7:56 [PATCH 0/2] mtd: spi-nor: Erase fixes Tudor Ambarus 2021-11-06 7:56 ` Tudor Ambarus 2021-11-06 7:56 ` [PATCH 1/2] mtd: spi-nor: Fix shift-out-of-bounds Tudor Ambarus 2021-11-06 7:56 ` Tudor Ambarus 2021-11-08 9:26 ` (EXT) " Stein, Alexander 2021-11-08 9:26 ` Stein, Alexander 2021-11-16 18:36 ` Pratyush Yadav 2021-11-16 18:36 ` Pratyush Yadav 2022-03-16 7:39 ` Alexander Stein 2022-03-16 7:39 ` Alexander Stein 2022-03-16 7:47 ` Tudor.Ambarus 2022-03-16 7:47 ` Tudor.Ambarus 2023-01-23 15:02 ` Stein, Alexander 2023-01-23 15:02 ` Stein, Alexander 2021-11-06 7:56 ` Tudor Ambarus [this message] 2021-11-06 7:56 ` [PATCH 2/2] mtd: spi-nor: Skip erase logic when SPI_NOR_NO_ERASE is set Tudor Ambarus 2021-12-06 18:17 ` Pratyush Yadav 2021-12-06 18:17 ` Pratyush Yadav
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20211106075616.95401-3-tudor.ambarus@microchip.com \ --to=tudor.ambarus@microchip.com \ --cc=Alexander.Stein@tq-group.com \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-mtd@lists.infradead.org \ --cc=michael@walle.cc \ --cc=p.yadav@ti.com \ --cc=vigneshr@ti.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.