Let the flash context directly point to the used master
We used to have a pointer to a full `registered_master` struct in
our flash context. Beside the used master, this contained a bit
mask of supported buses. Oddly convenient, this bit mask invited
to bypass the chip driver and break the abstraction. It allowed
to place bus-specific details virtually anywhere in flashprog,
making it harder to find a good place for them.
So, get rid of the `buses_supported` bit mask by pointing directly
to the master. Only the chip driver will implicitly know which type
of master is used.
Change-Id: I9ce13d8df0e7ccc67519d888dd9cb2e2ff8d6682
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/72533
diff --git a/dirtyjtag_spi.c b/dirtyjtag_spi.c
index 3074489..e648cfa 100644
--- a/dirtyjtag_spi.c
+++ b/dirtyjtag_spi.c
@@ -174,7 +174,7 @@
unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr)
{
- struct dirtyjtag_spi_data *context = flash->mst->spi.data;
+ struct dirtyjtag_spi_data *context = flash->mst.spi->data;
const size_t max_xfer_size = 30; // max transfer size in DJTAG1
size_t len = writecnt + readcnt;
size_t num_xfer = (len + max_xfer_size - 1 ) / max_xfer_size; // ceil(len/max_xfer_size)
@@ -224,7 +224,7 @@
unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr)
{
- struct dirtyjtag_spi_data *const context = flash->mst->spi.data;
+ struct dirtyjtag_spi_data *const context = flash->mst.spi->data;
const size_t max_xfer_size = 62; /* max transfer size in DJTAG2 */
uint8_t transfer_buffer[2 + max_xfer_size]; /* 1B command + 1B len + payload */
size_t i;