diff options
author | Anastasia Klimchuk <aklm@chromium.org> | 2021-08-03 15:45:19 +1000 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2021-08-25 02:23:34 +0000 |
commit | 9db8e12c169aa5a74154d9fb9993af8044afe39f (patch) | |
tree | 66f5056031aa03f6f35643e3e1536d8b888ce722 /linux_mtd.c | |
parent | cf6668b86b0978867c2385f5311894709374a11c (diff) | |
download | flashrom-9db8e12c169aa5a74154d9fb9993af8044afe39f.tar.gz flashrom-9db8e12c169aa5a74154d9fb9993af8044afe39f.tar.bz2 flashrom-9db8e12c169aa5a74154d9fb9993af8044afe39f.zip |
opaque_master: Use new API to register shutdown function
This allows opaque masters to register shutdown function in
opaque_master struct, which means there is no need to call
register_shutdown in init function, since this call is now a part
of register_opaque_master.
As a consequence of using new API, two things are happening here:
1) No resource leakage anymore in case register_shutdown() would fail,
2) Fixed propagation of register_opaque_master() return values.
BUG=b:185191942
TEST=1) builds and ninja test including CB:56413
2) on ARMv7 device
flashrom -p linux_mtd -V
-> using linux_mtd, chip found
Change-Id: Id8471a117556edcbf9694752fabe05cf4501ce70
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56825
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'linux_mtd.c')
-rw-r--r-- | linux_mtd.c | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/linux_mtd.c b/linux_mtd.c index 42d569d1..04eccde2 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -314,6 +314,7 @@ static const struct opaque_master linux_mtd_opaque_master = { .read = linux_mtd_read, .write = linux_mtd_write, .erase = linux_mtd_erase, + .shutdown = linux_mtd_shutdown, }; /* Returns 0 if setup is successful, non-zero to indicate error */ @@ -418,14 +419,7 @@ static int linux_mtd_init(void) return 1; } - if (register_shutdown(linux_mtd_shutdown, (void *)data)) { - free(data); - return 1; - } - - register_opaque_master(&linux_mtd_opaque_master, data); - - return 0; + return register_opaque_master(&linux_mtd_opaque_master, data); linux_mtd_init_exit: free(param); |