1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-26 22:52:34 +02:00

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>
This commit is contained in:
Anastasia Klimchuk 2021-08-03 14:08:02 +10:00 committed by Nico Huber
parent c87a770f5d
commit c845e64b4f
2 changed files with 8 additions and 0 deletions

View File

@ -50,6 +50,13 @@ int register_opaque_master(const struct opaque_master *mst, void *data)
{ {
struct registered_master rmst = {0}; 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) { if (!mst->probe || !mst->read || !mst->write || !mst->erase) {
msg_perr("%s called with incomplete master definition. " msg_perr("%s called with incomplete master definition. "
"Please report a bug at flashrom@flashrom.org\n", "Please report a bug at flashrom@flashrom.org\n",

View File

@ -443,6 +443,7 @@ struct opaque_master {
int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); 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 (*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 (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
int (*shutdown)(void *data);
void *data; void *data;
}; };
int register_opaque_master(const struct opaque_master *mst, void *data); int register_opaque_master(const struct opaque_master *mst, void *data);