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/linux_spi.c b/linux_spi.c
index 891c493..37b242d 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -206,7 +206,7 @@
const unsigned char *txbuf,
unsigned char *rxbuf)
{
- struct linux_spi_data *spi_data = flash->mst->spi.data;
+ struct linux_spi_data *spi_data = flash->mst.spi->data;
int iocontrol_code;
struct spi_ioc_transfer msg[2] = {
{
@@ -242,7 +242,7 @@
static int linux_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
{
- struct linux_spi_data *spi_data = flash->mst->spi.data;
+ struct linux_spi_data *spi_data = flash->mst.spi->data;
/* Older kernels use a single buffer for combined input and output
data. So account for longest possible command + address, too. */
return spi_read_chunked(flash, buf, start, len, spi_data->max_kernel_buf_size - 5);
@@ -250,7 +250,7 @@
static int linux_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len)
{
- struct linux_spi_data *spi_data = flash->mst->spi.data;
+ struct linux_spi_data *spi_data = flash->mst.spi->data;
/* 5 bytes must be reserved for longest possible command + address. */
return spi_write_chunked(flash, buf, start, len, spi_data->max_kernel_buf_size - 5);
}