spi: Pass master instead of flash to .send_command
In the SPI-master API, `.send_command` should only forward commands to
the SPI bus. All details about the commands and the SPI slave should be
handled in the chip driver. Hence, replace the `flashctx` pointer with
one to the `spi_master` to enforce proper separation.
Change-Id: I50934a1294217794b7e23cc98ade7e4279c059a1
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/74897
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
diff --git a/dirtyjtag_spi.c b/dirtyjtag_spi.c
index e648cfa..c3c768e 100644
--- a/dirtyjtag_spi.c
+++ b/dirtyjtag_spi.c
@@ -170,11 +170,11 @@
return dirtyjtag_send(context, tms_reset_buffer, sizeof(tms_reset_buffer));
}
-static int dirtyjtag_djtag1_spi_send_command(const struct flashctx *flash,
+static int dirtyjtag_djtag1_spi_send_command(const struct spi_master *mst,
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 = mst->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)
@@ -220,11 +220,11 @@
return -1;
}
-static int dirtyjtag_djtag2_spi_send_command(const struct flashctx *flash,
+static int dirtyjtag_djtag2_spi_send_command(const struct spi_master *mst,
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 = mst->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;