programmer: Smoothen register_opaque_master() API

It was impossible to register a const struct opaque_master that would
point to dynamically allocated `data`. Fix that so that we won't
have to create more mutable globals.

Change-Id: Id3adb4cf04ae04dbe87ddb96f30871cb5f7c8ff0
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/54170
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Original-Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72202
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 ab39100..a3e0465 100644
--- a/opaque.c
+++ b/opaque.c
@@ -46,7 +46,7 @@
 	return flash->mst->opaque.erase(flash, blockaddr, blocklen);
 }
 
-int register_opaque_master(const struct opaque_master *mst)
+int register_opaque_master(const struct opaque_master *mst, void *data)
 {
 	struct registered_master rmst;
 
@@ -58,5 +58,7 @@
 	}
 	rmst.buses_supported = BUS_PROG;
 	rmst.opaque = *mst;
+	if (data)
+		rmst.opaque.data = data;
 	return register_master(&rmst);
 }