u-boot/drivers
Marek Behún a60397d219 mtd: mtdpart: Make mtdpart's _erase method sane
The _erase() method of the mtdpart driver, part_erase(), currently
implements offset shifting (for given mtdpart partition) in a weird way:
  1. part_erase() adds partition offset to block address
  2. parent driver's _erase() method is called
  3. parent driver's _erase() method calls mtd_erase_callback()
  4. mtd_erase_callback() subtracts partition offset from block address
     so that the callback function is given correct address
The problem here is that if the parent's driver does not call
mtd_erase_callback() in some scenario (this was recently a case for
spi_nor_erase(), which did not call mtd_erase_callback() at all), the
offset is not shifted back.

Moreover the code would be more readable if part_erase() not only added
partition offset before calling parent's _erase(), but also subtracted
it back afterwards. Currently the mtd_erase_callback() is expected to do
this subtracting since it does have to do it anyway.

Add the more steps to this procedure:
  5. mtd_erase_callback() adds partition offset to block address so that
     it returns the the erase_info structure members as it received them
  6. part_erase() subtracts partition offset from block address

This makes the code more logical and also prevents errors in case
parent's driver does not call mtd_erase_callback() for some reason.

(BTW, the purpose of mtd_erase_callback() in Linux is to inform the
 caller that it is done, since in Linux erasing is done asynchronously.
 We are abusing the purpose of mtd_erase_callback() in U-Boot for
 completely different purpose. The callback function itself has empty
 implementation in all cases in U-Boot.)

Signed-off-by: Marek Behún <marek.behun@nic.cz>
Reviewed-by: Simon Glass <sjg@chromium.org>
Tested-by: Masami Hiramatsu <masami.hiramatsu@linaro.org>
2021-10-23 15:47:33 +05:30
..
adc dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
ata pci: Fix mismerge with v2021.10-rc4 2021-09-16 11:46:44 -04:00
axi WS cleanup: remove trailing empty lines 2021-09-30 08:08:56 -04:00
bios_emulator pci: Drop DM_PCI check from bios_emul 2021-08-05 19:46:35 -04:00
block Kconfig: Remove all default n/no options 2021-08-31 17:47:49 -04:00
bootcount bootcount: add a new driver with syscon as backend 2021-08-22 11:04:52 +02:00
bus bus: ti-sysc: change in a normal driver 2021-03-22 19:23:27 +13:00
button dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
cache WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
clk clk: k210: Try harder to get the best config 2021-10-07 16:08:23 +08:00
core treewide: Use OF_REAL instead of !OF_PLATDATA 2021-09-25 09:46:15 -06:00
cpu sandbox: correct cpu nodes 2021-09-25 09:46:15 -06:00
crypto WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
ddr WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
demo demo: migrate uclass to livetree 2021-10-05 08:50:15 -04:00
dfu Kconfig: Remove all default n/no options 2021-08-31 17:47:49 -04:00
dma ti: keystone: dma: Migrate to Kconfig 2021-09-27 21:38:34 -04:00
fastboot Kconfig: Remove all default n/no options 2021-08-31 17:47:49 -04:00
firmware WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
fpga WS cleanup: remove trailing empty lines 2021-09-30 08:08:56 -04:00
gpio gpio: Factor out DT flag translation 2021-10-05 08:50:15 -04:00
hwspinlock dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
i2c WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
input i8042: Do not abuse CONFIG namespace 2021-08-30 14:13:28 -04:00
led dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
mailbox dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
memory keystone2: Move CONFIG_AEMIF_CNTRL_BASE out of CONFIG namespace 2021-09-27 21:38:34 -04:00
misc WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
mmc arm: Remove aspenite board 2021-10-01 12:10:09 -04:00
mtd mtd: mtdpart: Make mtdpart's _erase method sane 2021-10-23 15:47:33 +05:30
mux dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
net arm: Remove zmx25 board and ARCH_MX25 2021-10-01 21:08:18 -04:00
nvme dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
pch treewide: Simply conditions with the new OF_REAL 2021-09-25 09:46:15 -06:00
pci pci: pcie_dw_meson: fix usb fail when pci link fails to go up 2021-10-07 10:14:50 +02:00
pci_endpoint dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
phy WS cleanup: remove trailing empty lines 2021-09-30 08:08:56 -04:00
pinctrl pinctrl: single: Add request() api 2021-10-05 08:43:03 -04:00
power WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
pwm WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
qe net: qe: uec: ensure mdiodev->name is NULL terminated after MDIO_NAME_LEN truncation 2021-09-28 18:50:56 +03:00
ram WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
reboot-mode reboot-mode: migrate uclass to livetree 2021-10-05 08:50:15 -04:00
remoteproc remoteproc: migrate uclass to livetree 2021-10-05 08:50:15 -04:00
reset WS cleanup: remove trailing white space 2021-09-30 08:08:56 -04:00
rng Kconfig: Remove all default n/no options 2021-08-31 17:47:49 -04:00
rtc rtc: rx8025: revise single register write to use offset 2021-10-03 14:40:56 -04:00
scsi sata: Rename SATA_SUPPORT to SATA 2021-09-04 12:26:02 -04:00
serial serial: Add a debug console using the RISC-V SBI interface 2021-10-07 16:08:23 +08:00
smem dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
soc soc: xilinx: versal: Add soc_xilinx_versal driver 2021-08-26 08:08:11 +02:00
sound dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
spi Merge branch 'next' 2021-10-04 11:28:16 -04:00
spmi dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
sysinfo sysinfo: rcar3: Add Renesas R-Car Gen3 sysinfo driver 2021-07-20 23:33:54 +02:00
sysreset sysreset: provide SBI based sysreset driver 2021-10-07 16:08:23 +08:00
tee tee: optee: sync cache on pre-reloc OP-TEE invocation 2021-07-23 07:13:25 -04:00
thermal WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
timer WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
tpm treewide: Simply conditions with the new OF_REAL 2021-09-25 09:46:15 -06:00
ufs dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
usb usb: dwc3: meson-gxl: add AXG compatible 2021-10-07 10:14:50 +02:00
video WS cleanup: remove SPACE(s) followed by TAB 2021-09-30 09:08:16 -04:00
virtio pci: Drop DM_PCI 2021-09-13 18:23:13 -04:00
w1 arm: Remove zmx25 board and ARCH_MX25 2021-10-01 21:08:18 -04:00
w1-eeprom dm: define LOG_CATEGORY for all uclass 2021-07-06 10:38:03 -06:00
watchdog watchdog: rti_wdt: Add support for loading firmware 2021-10-03 14:40:56 -04:00
xen WS cleanup: remove trailing empty lines 2021-09-30 08:08:56 -04:00
Kconfig reboot-mode: add support for reboot mode control 2021-07-23 10:16:39 -04:00
Makefile net: Move network rules to drivers/net 2021-09-04 12:51:47 -04:00