Home
last modified time | relevance | path

Searched hist:"1 ed65f0297874bd2af8ba83ac8425b97b338860b" (Results 1 – 1 of 1) sorted by relevance

/rk3399_rockchip-uboot/drivers/mtd/spi/
H A Dsf_mtd.c1ed65f0297874bd2af8ba83ac8425b97b338860b Sun Dec 02 09:54:32 UTC 2018 Boris Brezillon <boris.brezillon@bootlin.com> UPSTREAM: 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.

Change-Id: I5dc19ed7c6d6809957a5968c3790f01c32c26acb
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Tested-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Jon Lin <jon.lin@rock-chips.com>
(cherry picked from commit 08898e8b22d74a4511eadee9b06b11aab43e809c)