Nico Huber submitted this change.
opaque_master: Add shutdown function in opaque_master struct
With this, register_opaque_master can take care of register_shutdown
as well, and every opaque master only needs to call
register_opaque_master instead of calling both register_opaque_master
and register_shutdown.
Next patches in the chain convert opaque masters to use new API.
BUG=b:185191942
TEST=builds and ninja test from CB:56413
Change-Id: I34183e6bafc787eec54ee4a26b73a40803f3ce99
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56823
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
---
M opaque.c
M programmer.h
2 files changed, 8 insertions(+), 0 deletions(-)
diff --git a/opaque.c b/opaque.c
index f098ffc..7704ec7 100644
--- a/opaque.c
+++ b/opaque.c
@@ -50,6 +50,13 @@
{
struct registered_master rmst = {0};
+ if (mst->shutdown) {
+ if (register_shutdown(mst->shutdown, data)) {
+ mst->shutdown(data); /* cleanup */
+ return 1;
+ }
+ }
+
if (!mst->probe || !mst->read || !mst->write || !mst->erase) {
msg_perr("%s called with incomplete master definition. "
"Please report a bug at flashrom@flashrom.org\n",
diff --git a/programmer.h b/programmer.h
index ec55987..3de87e5 100644
--- a/programmer.h
+++ b/programmer.h
@@ -443,6 +443,7 @@
int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
int (*write) (struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
+ int (*shutdown)(void *data);
void *data;
};
int register_opaque_master(const struct opaque_master *mst, void *data);
To view, visit change 56823. To unsubscribe, or for help writing mail filters, visit settings.