Anastasia Klimchuk has uploaded this change for review.

View 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>
---
M opaque.c
M programmer.h
2 files changed, 8 insertions(+), 0 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/23/56823/1
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 95e2cda..074dd32 100644
--- a/programmer.h
+++ b/programmer.h
@@ -442,6 +442,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.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I34183e6bafc787eec54ee4a26b73a40803f3ce99
Gerrit-Change-Number: 56823
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-MessageType: newchange