Anastasia Klimchuk has uploaded this change for review.

View Change

programmer: Make use of new register_opaque_master() API

Pass pointers to dynamically allocated data to
register_opaque_master(). This way we can avoid some mutable globals.

BUG=b:185191942
TEST=builds

Change-Id: I160810cd67f782131962e96fc6d20e2987fb0390
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
---
M linux_mtd.c
1 file changed, 2 insertions(+), 3 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/71/54171/1
diff --git a/linux_mtd.c b/linux_mtd.c
index aeaecce..a1af069 100644
--- a/linux_mtd.c
+++ b/linux_mtd.c
@@ -295,7 +295,7 @@
return 0;
}

-static struct opaque_master programmer_linux_mtd = {
+static const struct opaque_master programmer_linux_mtd = {
/* max_data_{read,write} don't have any effect for this programmer */
.max_data_read = MAX_DATA_UNSPECIFIED,
.max_data_write = MAX_DATA_UNSPECIFIED,
@@ -418,13 +418,12 @@
goto linux_mtd_init_exit;
}

- programmer_linux_mtd.data = data;
if (register_shutdown(linux_mtd_shutdown, (void *)data)) {
free(data);
goto linux_mtd_init_exit;
}

- register_opaque_master(&programmer_linux_mtd, NULL);
+ register_opaque_master(&programmer_linux_mtd, data);

ret = 0;
linux_mtd_init_exit:

To view, visit change 54171. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I160810cd67f782131962e96fc6d20e2987fb0390
Gerrit-Change-Number: 54171
Gerrit-PatchSet: 1
Gerrit-Owner: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-MessageType: newchange