diff mbox series

[RESEND,u-boot-spi,1/8] mtd: spi-nor-core: Try cleaning up in case writing BAR failed

Message ID 20210714235109.25228-2-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
Use the cleanup codepath of spi_nor_erase() also in the event of failure
of writing the BAR register.

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 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Simon Glass July 20, 2021, 6:32 p.m. UTC | #1
On Wed, 14 Jul 2021 at 17:51, Marek Behún <marek.behun@nic.cz> wrote:
>
> Use the cleanup codepath of spi_nor_erase() also in the event of failure
> of writing the BAR register.
>
> 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 | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Reviewed-by: Simon Glass <sjg@chromium.org>
Jagan Teki July 21, 2021, 3:49 p.m. UTC | #2
On Thu, Jul 15, 2021 at 5:21 AM Marek Behún <marek.behun@nic.cz> wrote:
>
> Use the cleanup codepath of spi_nor_erase() also in the event of failure
> of writing the BAR register.
>
> Signed-off-by: Marek Behún <marek.behun@nic.cz>
> Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
> ---

Reviewed-by: Jagan Teki <jagan@amarulasolutions.com>
diff mbox series

Patch

diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c
index 99e2f16349..7ce8dc5502 100644
--- a/drivers/mtd/spi/spi-nor-core.c
+++ b/drivers/mtd/spi/spi-nor-core.c
@@ -927,7 +927,7 @@  static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr)
 #ifdef CONFIG_SPI_FLASH_BAR
 		ret = write_bar(nor, addr);
 		if (ret < 0)
-			return ret;
+			goto erase_err;
 #endif
 		write_enable(nor);