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/at45db.c b/at45db.c
index 463442c..acde996 100644
--- a/at45db.c
+++ b/at45db.c
@@ -241,7 +241,7 @@
/* We have to split this up into chunks to fit within the programmer's read size limit, but those
* chunks can cross page boundaries. */
- const unsigned int max_data_read = flash->mst->spi.max_data_read;
+ const unsigned int max_data_read = flash->mst.spi->max_data_read;
const unsigned int max_chunk = (max_data_read > 0) ? max_data_read : page_size;
while (len > 0) {
unsigned int chunk = min(max_chunk, len);
@@ -272,7 +272,7 @@
/* We have to split this up into chunks to fit within the programmer's read size limit, but those
* chunks can cross page boundaries. */
- const unsigned int max_data_read = flash->mst->spi.max_data_read;
+ const unsigned int max_data_read = flash->mst.spi->max_data_read;
const unsigned int max_chunk = (max_data_read > 0) ? max_data_read : page_size;
while (len > 0) {
const unsigned int addr_at45 = at45db_convert_addr(addr, page_size);
@@ -463,7 +463,7 @@
}
/* Create a suitable buffer to store opcode, address and data chunks for buffer1. */
- const unsigned int max_data_write = flash->mst->spi.max_data_write;
+ const unsigned int max_data_write = flash->mst.spi->max_data_write;
const unsigned int max_chunk = max_data_write > 4 && max_data_write - 4 <= page_size ?
max_data_write - 4 : page_size;
uint8_t buf[4 + max_chunk];