mirror of
https://github.com/u-boot/u-boot.git
synced 2025-05-08 10:39:08 +00:00
sf: Fix NULL pointer exception for flashes without lock methods
commit c3c016c
"sf: Add SPI NOR protection mechanism" introduced
flash_lock()/flash_unlock()/flash_is_locked() methods for SPI flash,
but not every flash driver supplies these. We should test these
methods against NULL before actually calling them.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Fabio Estevam <fabio.estevam@freescale.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>
This commit is contained in:
parent
9ac4fc8207
commit
439fcb9b4f
2 changed files with 13 additions and 7 deletions
|
@ -237,7 +237,7 @@ static inline int spi_flash_erase(struct spi_flash *flash, u32 offset,
|
|||
static inline int spi_flash_protect(struct spi_flash *flash, u32 ofs, u32 len,
|
||||
bool prot)
|
||||
{
|
||||
if (!flash->flash_lock)
|
||||
if (!flash->flash_lock || !flash->flash_unlock)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (prot)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue