[Skiboot] [PATCH 1/2] libflash: don't use the low level interface if it doesn't exist

Cyril Bur cyril.bur at au1.ibm.com
Wed Apr 1 16:51:03 AEDT 2015


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 at au1.ibm.com>
---
 libflash/libflash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/libflash/libflash.c b/libflash/libflash.c
index 5b8a0ac..bb6f097 100644
--- a/libflash/libflash.c
+++ b/libflash/libflash.c
@@ -668,6 +668,10 @@ static int flash_set_4b(struct flash_chip *c, bool enable)
 	struct spi_flash_ctrl *ct = c->ctrl;
 	int rc;
 
+	/* Don't have low level interface, assume all is well */
+	if (!ct->cmd_wr)
+		return 0;
+
 	/* Some flash chips want this */
 	rc = fl_wren(ct);
 	if (rc) {
@@ -676,7 +680,6 @@ static int flash_set_4b(struct flash_chip *c, bool enable)
 	}
 
 	/* Ignore error in case chip is write protected */
-
 	return ct->cmd_wr(ct, enable ? CMD_EN4B : CMD_EX4B, false, 0, NULL, 0);
 }
 
@@ -758,7 +761,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");
-- 
1.9.1



More information about the Skiboot mailing list