aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--programmer.h1
-rw-r--r--spi.c7
2 files changed, 8 insertions, 0 deletions
diff --git a/programmer.h b/programmer.h
index 95e2cdaf..ec559872 100644
--- a/programmer.h
+++ b/programmer.h
@@ -356,6 +356,7 @@ struct spi_master {
int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
int (*write_256)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
int (*write_aai)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
+ int (*shutdown)(void *data);
void *data;
};
diff --git a/spi.c b/spi.c
index 4ac39145..f2e91c4d 100644
--- a/spi.c
+++ b/spi.c
@@ -135,6 +135,13 @@ int register_spi_master(const struct spi_master *mst, void *data)
{
struct registered_master rmst = {0};
+ if (mst->shutdown) {
+ if (register_shutdown(mst->shutdown, data)) {
+ mst->shutdown(data); /* cleanup */
+ return 1;
+ }
+ }
+
if (!mst->write_aai || !mst->write_256 || !mst->read || !mst->command ||
!mst->multicommand ||
((mst->command == default_spi_send_command) &&