Run .prepare_access only once per flash context

There's only a single path now to create a flash context,  after
probing, and only when we want to access the flash chip next. So
there's no need to defer this preparation step anymore.

All preparation will be done in a single step. Hence we drop the
PREPARE_POST_PROBE and PREPARE_FULL steps and the enum.

Change-Id: I7cd4058dd0b52ad0e4be45e494c4533f689893d9
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/492
diff --git a/sfdp.c b/sfdp.c
index a324f9c..b1d7777 100644
--- a/sfdp.c
+++ b/sfdp.c
@@ -342,7 +342,7 @@
 	return 0;
 }
 
-int spi_prepare_sfdp(struct flashctx *flash, enum preparation_steps step)
+int spi_prepare_sfdp(struct flashctx *flash)
 {
 	const struct spi_master *const spi = flash->mst.spi;
 	int ret;
@@ -355,9 +355,6 @@
 	uint8_t *hbuf;
 	uint8_t *tbuf;
 
-	if (step != PREPARE_POST_PROBE)
-		return 0;
-
 	ret = spi_sfdp_read_sfdp(spi, 0x04, buf, 3);
 	if (ret) {
 		msg_cdbg("Receiving SFDP revision and number of parameter "
@@ -490,7 +487,12 @@
 		  "Thanks for your help!\n"
 		  "===\n");
 
-	return 0;
+	/* Chain preparation in case we replaced the .prepare_access
+	   pointer, e.g. spi_prepare_io() is needed for 4BA mode. */
+	if (flash->chip->prepare_access != spi_prepare_sfdp)
+		ret = flash->chip->prepare_access(flash);
+
+	return ret;
 }
 
 struct found_id *probe_spi_sfdp(const struct bus_probe *probe,