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/ft4222_spi.c b/ft4222_spi.c
index 46fa698..9709154 100644
--- a/ft4222_spi.c
+++ b/ft4222_spi.c
@@ -484,11 +484,11 @@
}
static int ft4222_spi_send_command(
- const struct flashctx *const flash,
+ const struct spi_master *const mst,
const unsigned int writecnt, const unsigned int readcnt,
const unsigned char *const writearr, unsigned char *const readarr)
{
- struct ft4222 *const ft4222 = flash->mst.spi->data;
+ struct ft4222 *const ft4222 = mst->data;
int ret, poll_ret;
ret = ft4222_spi_set_io_lines(ft4222, 1);
@@ -606,14 +606,14 @@
return ret ? ret : poll_ret;
}
-static int ft4222_spi_send_multicommand(const struct flashctx *flash, struct spi_command *cmds)
+static int ft4222_spi_send_multicommand(const struct spi_master *mst, struct spi_command *cmds)
{
- struct ft4222 *const ft4222 = flash->mst.spi->data;
+ struct ft4222 *const ft4222 = mst->data;
for (; !spi_is_empty(cmds); ++cmds) {
int ret;
if (cmds->io_mode == SINGLE_IO_1_1_1) {
- ret = ft4222_spi_send_command(flash, spi_write_len(cmds),
+ ret = ft4222_spi_send_command(mst, spi_write_len(cmds),
spi_read_len(cmds), cmds->writearr, cmds->readarr);
} else {
ret = ft4222_spi_send_multi_io(ft4222, cmds);