diff options
author | Cyril Bur <cyril.bur@au1.ibm.com> | 2015-03-19 18:18:20 +1100 |
---|---|---|
committer | Stewart Smith <stewart@linux.vnet.ibm.com> | 2015-04-01 15:24:07 +1100 |
commit | 237f9d1a51eaed260119346dfddc044395267154 (patch) | |
tree | 9c0b88c108eeaf10af6cdfc3c11e0f99b017cfc5 /libflash | |
parent | e61506bcc11b887eb39c61a4657db75a1757c1f7 (diff) | |
download | skiboot-237f9d1a51eaed260119346dfddc044395267154.zip skiboot-237f9d1a51eaed260119346dfddc044395267154.tar.gz skiboot-237f9d1a51eaed260119346dfddc044395267154.tar.bz2 |
libflash: don't use the low level interface if it doesn't exist
During init libflash calls low level functions without checking.
libflash states to backends that if they implement all the higher level
functions the lower level functions are optional (from libflash-priv.h):
If all functions of the high level interface are
implemented then the low level one is optional. A
controller can implement some of the high level one
in which case the missing ones will be handled by
libflash using the low level interface.
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com>
Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
Diffstat (limited to 'libflash')
-rw-r--r-- | libflash/libflash.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/libflash/libflash.c b/libflash/libflash.c index 5b8a0ac..b5eaff5 100644 --- a/libflash/libflash.c +++ b/libflash/libflash.c @@ -92,6 +92,10 @@ int fl_wren(struct spi_flash_ctrl *ct) int i, rc; uint8_t stat; + /* If lower level interface not implmented, just return */ + if (!ct->cmd_wr) + return 0; + /* Some flashes need it to be hammered */ for (i = 0; i < 1000; i++) { rc = ct->cmd_wr(ct, CMD_WREN, false, 0, NULL, 0); @@ -675,6 +679,11 @@ static int flash_set_4b(struct flash_chip *c, bool enable) /* Ignore the error & move on (could be wrprotect chip) */ } + /* Don't have low level interface, assume all is well */ + if (!ct->cmd_wr) + return 0; + + /* Ignore error in case chip is write protected */ return ct->cmd_wr(ct, enable ? CMD_EN4B : CMD_EX4B, false, 0, NULL, 0); @@ -758,7 +767,6 @@ static int flash_configure(struct flash_chip *c) return rc; } } - /* Set controller to 3b mode if mode switch is supported */ if (ct->set_4b) { FL_DBG("LIBFLASH: Disabling controller 4B mode...\n"); |