[PATCH RESEND u-boot-spi 6/8] mtd: spi-nor-core: Call mtd_erase_callback() from spi_nor_erase()

Simon Glass sjg at chromium.org
Tue Jul 20 20:32:59 CEST 2021


On Wed, 14 Jul 2021 at 17:51, Marek Behún <marek.behun at nic.cz> wrote:
>
> The spi_nor_erase() function does not call mtd_erase_callback() as it
> should.
>
> The mtdpart code currently implements the subtraction of partition
> offset in mtd_erase_callback().
>
> This results in partition offset being added prior calling
> spi_nor_erase(), but not subtracted back on return. The result is that
> the `mtd erase` command does not erase the whole partition, only some of
> it's blocks:
>
>   => mtd erase "Rescue system"
>   Erasing 0x00000000 ... 0x006fffff (1792 eraseblock(s))
>   jedec_spi_nor spi-nor at 0: at 0x100000, len 4096
>   jedec_spi_nor spi-nor at 0: at 0x201000, len 4096
>   jedec_spi_nor spi-nor at 0: at 0x302000, len 4096
>   jedec_spi_nor spi-nor at 0: at 0x403000, len 4096
>   jedec_spi_nor spi-nor at 0: at 0x504000, len 4096
>   jedec_spi_nor spi-nor at 0: at 0x605000, len 4096
>   jedec_spi_nor spi-nor at 0: at 0x706000, len 4096
>
> This is obviously wrong.
>
> Add proper calling of mtd_erase_callback() into the spi_nor_erase()
> function.
>
> Signed-off-by: Marek Behún <marek.behun at nic.cz>
> Reported-by: Masami Hiramatsu <masami.hiramatsu at linaro.org>
> Tested-by: Masami Hiramatsu <masami.hiramatsu at linaro.org>
> ---
>  drivers/mtd/spi/spi-nor-core.c | 20 ++++++++++++++++++--
>  1 file changed, 18 insertions(+), 2 deletions(-)
>

Reviewed-by: Simon Glass <sjg at chromium.org>


More information about the U-Boot mailing list