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/memory_bus.c b/memory_bus.c
index ff6799e..365c53c 100644
--- a/memory_bus.c
+++ b/memory_bus.c
@@ -24,8 +24,8 @@
uintptr_t phys_addr, size_t len)
{
void *ret;
- if (flash->mst->par.map_flash)
- ret = flash->mst->par.map_flash(descr, phys_addr, len);
+ if (flash->mst.par->map_flash)
+ ret = flash->mst.par->map_flash(descr, phys_addr, len);
else
ret = fallback_map(descr, phys_addr, len);
msg_gspew("%s: mapping %s from 0x%0*" PRIxPTR " to 0x%0*" PRIxPTR "\n",
@@ -35,8 +35,8 @@
static void programmer_unmap_flash_region(const struct flashctx *flash, void *virt_addr, size_t len)
{
- if (flash->mst->par.unmap_flash)
- flash->mst->par.unmap_flash(virt_addr, len);
+ if (flash->mst.par->unmap_flash)
+ flash->mst.par->unmap_flash(virt_addr, len);
else
fallback_unmap(virt_addr, len);
msg_gspew("%s: unmapped 0x%0*" PRIxPTR "\n", __func__, PRIxPTR_WIDTH, (uintptr_t)virt_addr);