programmer: Make use of new register_opaque_master() API
Pass pointers to dynamically allocated data to
register_opaque_master(). This way we can avoid a mutable global.
Change-Id: I160810cd67f782131962e96fc6d20e2987fb0390
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/54171
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/+/72203
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/linux_mtd.c b/linux_mtd.c
index 6a9257f..3c58987 100644
--- a/linux_mtd.c
+++ b/linux_mtd.c
@@ -298,7 +298,7 @@
return 0;
}
-static struct opaque_master linux_mtd_opaque_master = {
+static const struct opaque_master linux_mtd_opaque_master = {
/* max_data_{read,write} don't have any effect for this programmer */
.max_data_read = MAX_DATA_UNSPECIFIED,
.max_data_write = MAX_DATA_UNSPECIFIED,
@@ -420,13 +420,12 @@
goto linux_mtd_init_exit;
}
- linux_mtd_opaque_master.data = data;
if (register_shutdown(linux_mtd_shutdown, (void *)data)) {
free(data);
goto linux_mtd_init_exit;
}
- register_opaque_master(&linux_mtd_opaque_master, NULL);
+ register_opaque_master(&linux_mtd_opaque_master, data);
ret = 0;
linux_mtd_init_exit: