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.

Tested: builds and ninja test from CB:56413

Change-Id: I34183e6bafc787eec54ee4a26b73a40803f3ce99
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/56823
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72229
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/opaque.c b/opaque.c
index a3e0465..d83e3bc 100644
--- a/opaque.c
+++ b/opaque.c
@@ -50,6 +50,13 @@
 {
 	struct registered_master rmst;
 
+	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.\n"
 			 "Please report a bug at flashrom-stable@flashrom.org\n",