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/opaque.c b/opaque.c
index 72bb131..eacc09f 100644
--- a/opaque.c
+++ b/opaque.c
@@ -28,22 +28,22 @@
int probe_opaque(struct flashctx *flash)
{
- return flash->mst->opaque.probe(flash);
+ return flash->mst.opaque->probe(flash);
}
int read_opaque(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
- return flash->mst->opaque.read(flash, buf, start, len);
+ return flash->mst.opaque->read(flash, buf, start, len);
}
int write_opaque(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len)
{
- return flash->mst->opaque.write(flash, buf, start, len);
+ return flash->mst.opaque->write(flash, buf, start, len);
}
int erase_opaque(struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen)
{
- return flash->mst->opaque.erase(flash, blockaddr, blocklen);
+ return flash->mst.opaque->erase(flash, blockaddr, blocklen);
}
int register_opaque_master(const struct opaque_master *mst, void *data)