diff mbox series

[RESEND,u-boot-spi,7/8] mtd: spi-nor-core: Check for ctrlc() in spi_nor_erase()

Message ID 20210714235109.25228-8-marek.behun@nic.cz
State Superseded
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series Fix `mtd erase` when used with mtdpart | expand

Commit Message

Marek Behún July 14, 2021, 11:51 p.m. UTC
May it possible to interrupt the spi_nor_erase() function.

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
---
 drivers/mtd/spi/spi-nor-core.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Simon Glass July 20, 2021, 6:33 p.m. UTC | #1
On Wed, 14 Jul 2021 at 17:51, Marek Behún <marek.behun@nic.cz> wrote:
>
> May it possible to interrupt the spi_nor_erase() function.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
> ---
>  drivers/mtd/spi/spi-nor-core.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 927823930c..81ecd1fe5a 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -927,6 +927,11 @@  static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
 
 	while (len) {
 		WATCHDOG_RESET();
+		if (ctrlc()) {
+			addr_known = false;
+			ret = -EINTR;
+			goto erase_err;
+		}
 #ifdef CONFIG_SPI_FLASH_BAR
 		ret = write_bar(nor, addr);
 		if (ret < 0)