par_master: Add shutdown function in par_master struct
With this, register_par_master can take care of register_shutdown
as well, and every par master only needs to call
register_par_master instead of calling both register_par_master
and register_shutdown.
Next patches in the chain convert par masters to use new API.
Tested: builds and ninja test
Change-Id: I0fee15d548cdd16678e551eeb351e659812ddf76
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/57154
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72232
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/programmer.c b/programmer.c
index 943886b..a8218a3 100644
--- a/programmer.c
+++ b/programmer.c
@@ -85,6 +85,14 @@
void *data)
{
struct registered_master rmst;
+
+ if (mst->shutdown) {
+ if (register_shutdown(mst->shutdown, data)) {
+ mst->shutdown(data); /* cleanup */
+ return 1;
+ }
+ }
+
if (!mst->chip_writeb || !mst->chip_writew || !mst->chip_writel ||
!mst->chip_writen || !mst->chip_readb || !mst->chip_readw ||
!mst->chip_readl || !mst->chip_readn) {
diff --git a/programmer.h b/programmer.h
index deaafc4..d392027 100644
--- a/programmer.h
+++ b/programmer.h
@@ -425,6 +425,7 @@
uint16_t (*chip_readw) (const struct flashctx *flash, const chipaddr addr);
uint32_t (*chip_readl) (const struct flashctx *flash, const chipaddr addr);
void (*chip_readn) (const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
+ int (*shutdown)(void *data);
void *data;
};
int register_par_master(const struct par_master *mst, const enum chipbustype buses, void *data);