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/include/programmer.h b/include/programmer.h
index df5f51f..5cef491 100644
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -311,9 +311,9 @@
uint32_t features;
unsigned int max_data_read; // (Ideally,) maximum data read size in one go (excluding opcode+address).
unsigned int max_data_write; // (Ideally,) maximum data write size in one go (excluding opcode+address).
- int (*command)(const struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
+ int (*command)(const struct spi_master *, unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
- int (*multicommand)(const struct flashctx *flash, struct spi_command *cmds);
+ int (*multicommand)(const struct spi_master *, struct spi_command *cmds);
/* Optimized functions for this master */
int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
@@ -324,9 +324,9 @@
void *data;
};
-int default_spi_send_command(const struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
+int default_spi_send_command(const struct spi_master *, unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr, unsigned char *readarr);
-int default_spi_send_multicommand(const struct flashctx *flash, struct spi_command *cmds);
+int default_spi_send_multicommand(const struct spi_master *, struct spi_command *cmds);
int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
int default_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
int default_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);