u-boot-brain/drivers/mtd/spi
Boris Brezillon 08898e8b22 mtd: sf: Make sf_mtd.c more robust
SPI flash based MTD devs can be registered/unregistered at any time
through the sf probe command or the spi_flash_free() function.

This commit does not try to fix the root cause as it would probably
require rewriting most of the code and have an mtd_info object
instance per spi_flash object (not to mention that the the spi-flash
layer is likely to be replaced by a spi-nor layer ported from Linux).

Instead, we try to be as safe as can be by checking the code returned
by del_mtd_device() and complain loudly when there's nothing we can
do about the deregistration failure. When that happens we also reset
sf_mtd_info.priv to NULL, and check for NULL pointer in the mtd hooks
so that -ENODEV is returned instead of hitting a NULL pointer
dereference exception when the MTD instance is later accessed by a user.

Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Heiko Schocher <hs@denx.de>
2018-12-06 00:45:36 +05:30
..
fsl_espi_spl.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
Kconfig sf: Add XMC xm25qh64a and xm25qh128a entries 2018-10-04 18:21:23 +05:30
Makefile SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sandbox.c dm: spi: Clean up detection of sandbox SPI emulator 2018-10-09 04:40:27 -06:00
sf_dataflash.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
sf_internal.h sf: Add MICRON manufacturer id 2018-10-12 11:37:49 +05:30
sf_mtd.c mtd: sf: Make sf_mtd.c more robust 2018-12-06 00:45:36 +05:30
sf_probe.c mtd: sf: Unregister the MTD device prior to removing the spi_flash obj 2018-12-06 00:45:36 +05:30
sf-uclass.c dm: spi: Add logging of some return values 2018-10-09 04:40:27 -06:00
sf.c SPDX: Convert all of our single license tags to Linux Kernel style 2018-05-07 09:34:12 -04:00
spi_flash_ids.c sf: Add XMC xm25qh64a and xm25qh128a entries 2018-10-04 18:21:23 +05:30
spi_flash.c Merge branch 'master' of git://git.denx.de/u-boot-spi 2018-10-12 11:54:13 -04:00