Anastasia Klimchuk has uploaded this change for review.
programmer: Introduce default shutdown function
Default shutdown function is only freeing master data (if data exists)
and not doing anything else.
There is one spi master which can use default shutdown function
(usbblaster, included in this patch), and a lot of par masters that
will use it in the nearest future.
BUG=b:185191942
TEST=builds
Change-Id: I8b20717ba549e12edffbc5d1643ff064a4f0c517
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M flashrom.c
M programmer.h
M usbblaster_spi.c
3 files changed, 9 insertions(+), 7 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/90/54890/1
diff --git a/flashrom.c b/flashrom.c
index 0af5057..069d59a 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -553,6 +553,13 @@
static int check_block_eraser(const struct flashctx *flash, int k, int log);
+int default_shutdown(void *data)
+{
+ if (data)
+ free(data);
+ return 0;
+}
+
/* Register a function to be executed on programmer shutdown.
* The advantage over atexit() is that you can supply a void pointer which will
* be used as parameter to the registered function upon programmer shutdown.
diff --git a/programmer.h b/programmer.h
index 790fcc8..17bfd2f 100644
--- a/programmer.h
+++ b/programmer.h
@@ -612,6 +612,7 @@
extern unsigned long flashbase;
unsigned int count_max_decode_exceedings(const struct flashctx *flash);
char *extract_programmer_param(const char *param_name);
+int default_shutdown(void *data);
/* spi.c */
#define MAX_DATA_UNSPECIFIED 0
diff --git a/usbblaster_spi.c b/usbblaster_spi.c
index 115876e..61edc2e 100644
--- a/usbblaster_spi.c
+++ b/usbblaster_spi.c
@@ -162,12 +162,6 @@
return ret;
}
-static int usbblaster_shutdown(void *data)
-{
- free(data);
- return 0;
-}
-
static const struct spi_master spi_master_usbblaster = {
.max_data_read = 256,
.max_data_write = 256,
@@ -227,7 +221,7 @@
}
usbblaster_data->ftdic = ftdic;
- if (register_shutdown(usbblaster_shutdown, usbblaster_data)) {
+ if (register_shutdown(default_shutdown, usbblaster_data)) {
free(usbblaster_data);
return -1;
}
To view, visit change 54890. To unsubscribe, or for help writing mail filters, visit settings.