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/include/chipdrivers/edi.h b/include/chipdrivers/edi.h
index 4d641cc..ad0e1db 100644
--- a/include/chipdrivers/edi.h
+++ b/include/chipdrivers/edi.h
@@ -29,6 +29,7 @@
 int edi_chip_block_erase(struct flashprog_flashctx *, unsigned int page, unsigned int size);
 int edi_chip_write(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
 int edi_chip_read(struct flashprog_flashctx *, uint8_t *buf, unsigned int start, unsigned int len);
-int edi_prepare(struct flashprog_flashctx *, enum preparation_steps);
+int edi_prepare(struct flashprog_flashctx *);
+void edi_finish(struct flashprog_flashctx *);
 
 #endif /* !__CHIPDRIVERS_EDI_H__ */
diff --git a/include/chipdrivers/memory_bus.h b/include/chipdrivers/memory_bus.h
index b4eede4..86a82a0 100644
--- a/include/chipdrivers/memory_bus.h
+++ b/include/chipdrivers/memory_bus.h
@@ -115,9 +115,8 @@
 void *programmer_map_flash_data(const struct par_master *, chipsize_t, const char *descr);
 void programmer_unmap_flash_region(const struct par_master *, void *, chipsize_t);
 
-enum preparation_steps;
-int prepare_memory_access(struct flashprog_flashctx *, enum preparation_steps);
-int prepare_memory_register_access(struct flashprog_flashctx *, enum preparation_steps);
+int prepare_memory_access(struct flashprog_flashctx *);
+int prepare_memory_register_access(struct flashprog_flashctx *);
 void finish_memory_access(struct flashprog_flashctx *);
 
 #endif /* !__CHIPDRIVERS_MEMORY_BUS_H__ */
diff --git a/include/chipdrivers/opaque.h b/include/chipdrivers/opaque.h
index d6d3eba..8d9f660 100644
--- a/include/chipdrivers/opaque.h
+++ b/include/chipdrivers/opaque.h
@@ -25,8 +25,7 @@
 
 struct found_id *probe_opaque(const struct bus_probe *, const struct master_common *, const struct flashchip *);
 
-enum preparation_steps;
-int prepare_opaque(struct flashprog_flashctx *, enum preparation_steps);
+int prepare_opaque(struct flashprog_flashctx *);
 
 int read_opaque(struct flashprog_flashctx *, uint8_t *buf, unsigned int start, unsigned int len);
 int write_opaque(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len);
diff --git a/include/chipdrivers/spi.h b/include/chipdrivers/spi.h
index 94a6a1f..d99d903 100644
--- a/include/chipdrivers/spi.h
+++ b/include/chipdrivers/spi.h
@@ -57,8 +57,7 @@
 int spi_write_chunked(struct flashprog_flashctx *, const uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize);
 int spi_set_extended_address(struct flashprog_flashctx *, uint8_t addr_high);
 
-enum preparation_steps;
-int spi_prepare_io(struct flashprog_flashctx *, enum preparation_steps);
+int spi_prepare_io(struct flashprog_flashctx *);
 void spi_finish_io(struct flashprog_flashctx *);
 
 enum flash_reg;
@@ -107,7 +106,7 @@
 int spi_disable_blockprotect_sst26_global_unprotect(struct flashprog_flashctx *);
 
 /* at45db.c */
-int spi_prepare_at45db(struct flashprog_flashctx *, enum preparation_steps);
+int spi_prepare_at45db(struct flashprog_flashctx *);
 int spi_prettyprint_status_register_at45db(struct flashprog_flashctx *);
 int spi_disable_blockprotect_at45db(struct flashprog_flashctx *);
 int spi_read_at45db(struct flashprog_flashctx *, uint8_t *buf, unsigned int start, unsigned int len);
@@ -132,6 +131,6 @@
 
 /* sfdp.c */
 struct found_id *probe_spi_sfdp(const struct bus_probe *, const struct master_common *, const struct flashchip *);
-int spi_prepare_sfdp(struct flashprog_flashctx *, enum preparation_steps);
+int spi_prepare_sfdp(struct flashprog_flashctx *);
 
 #endif /* !__CHIPDRIVERS_SPI_H__ */