memory_bus: Pass master instead of flash to .chip_read/write
There is / should be no need to know flash-chip details in a programmer
driver. They should only pass data around and leave the chip details to
each chip driver.
This will allow us to probe for chips before knowing the details and as
a bonus gets rid of many `flash.h` dependencies.
Change-Id: Iae78fbbd95567134da890613114999cb14c3a011
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/437
diff --git a/serprog.c b/serprog.c
index e1d33ed..a596966 100644
--- a/serprog.c
+++ b/serprog.c
@@ -35,9 +35,7 @@
#endif
#include <string.h>
#include <errno.h>
-#include "flash.h"
#include "programmer.h"
-#include "chipdrivers.h"
/* According to Serial Flasher Protocol Specification - version 1 */
#define S_ACK 0x06
@@ -371,12 +369,9 @@
.probe_opcode = default_spi_probe_opcode,
};
-static void serprog_chip_writeb(const struct flashctx *flash, uint8_t val,
- chipaddr addr);
-static uint8_t serprog_chip_readb(const struct flashctx *flash,
- const chipaddr addr);
-static void serprog_chip_readn(const struct flashctx *flash, uint8_t *buf,
- const chipaddr addr, size_t len);
+static void serprog_chip_writeb(const struct par_master *, uint8_t val, chipaddr);
+static uint8_t serprog_chip_readb(const struct par_master *, chipaddr);
+static void serprog_chip_readn(const struct par_master *, uint8_t *buf, chipaddr, size_t len);
static void *serprog_map(const char *descr, uintptr_t phys_addr, size_t len);
static const struct par_master par_master_serprog = {
.chip_readb = serprog_chip_readb,
@@ -877,8 +872,7 @@
return 0;
}
-static void serprog_chip_writeb(const struct flashctx *flash, uint8_t val,
- chipaddr addr)
+static void serprog_chip_writeb(const struct par_master *par, uint8_t val, chipaddr addr)
{
msg_pspew("%s\n", __func__);
if (sp_max_write_n) {
@@ -909,8 +903,7 @@
}
}
-static uint8_t serprog_chip_readb(const struct flashctx *flash,
- const chipaddr addr)
+static uint8_t serprog_chip_readb(const struct par_master *par, const chipaddr addr)
{
unsigned char c;
unsigned char buf[3];
@@ -954,8 +947,7 @@
}
/* The externally called version that makes sure that max_read_n is obeyed. */
-static void serprog_chip_readn(const struct flashctx *flash, uint8_t * buf,
- const chipaddr addr, size_t len)
+static void serprog_chip_readn(const struct par_master *par, uint8_t * buf, const chipaddr addr, size_t len)
{
size_t lenm = len;
chipaddr addrm = addr;