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/linux_spi.c b/linux_spi.c
index bf8d7f2..dda3808 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -50,10 +50,9 @@
};
static int linux_spi_shutdown(void *data);
-static int linux_spi_send_command(const struct flashctx *flash, unsigned int writecnt,
- unsigned int readcnt,
- const unsigned char *txbuf,
- unsigned char *rxbuf);
+static int linux_spi_send_command(
+ const struct spi_master *, unsigned int writecnt, unsigned int readcnt,
+ const unsigned char *txbuf, unsigned char *rxbuf);
static const struct spi_master spi_master_linux = {
.features = SPI_MASTER_4BA,
@@ -203,12 +202,11 @@
return 0;
}
-static int linux_spi_send_command(const struct flashctx *flash, unsigned int writecnt,
- unsigned int readcnt,
- const unsigned char *txbuf,
- unsigned char *rxbuf)
+static int linux_spi_send_command(
+ const struct spi_master *mst, unsigned int writecnt, unsigned int readcnt,
+ const unsigned char *txbuf, unsigned char *rxbuf)
{
- struct linux_spi_data *spi_data = flash->mst.spi->data;
+ struct linux_spi_data *spi_data = mst->data;
int iocontrol_code;
struct spi_ioc_transfer msg[2] = {
{