mtd: spi-nor-core: Call mtd_erase_callback() from spi_nor_erase()
authorMarek Behún <marek.behun@nic.cz>
Tue, 5 Oct 2021 13:56:03 +0000 (15:56 +0200)
committerJagan Teki <jagan@amarulasolutions.com>
Sat, 23 Oct 2021 10:17:33 +0000 (15:47 +0530)
commitff0000b47d7945701b2f9d17cc301b54452d499b
tree4fee72cec2b95b0d35fdab4c953083bfd88cb4e6
parent7398c1b758e70708edc1d0aced2e2b07ded1ed7e
mtd: spi-nor-core: Call mtd_erase_callback() from spi_nor_erase()

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@0: at 0x100000, len 4096
  jedec_spi_nor spi-nor@0: at 0x201000, len 4096
  jedec_spi_nor spi-nor@0: at 0x302000, len 4096
  jedec_spi_nor spi-nor@0: at 0x403000, len 4096
  jedec_spi_nor spi-nor@0: at 0x504000, len 4096
  jedec_spi_nor spi-nor@0: at 0x605000, len 4096
  jedec_spi_nor spi-nor@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@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reported-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
drivers/mtd/spi/spi-nor-core.c