>From 79074bc2b30f42d7f68cf4ef84cfc84f7c169ec4 Mon Sep 17 00:00:00 2001
From: Tadas Slotkus <devtadas@gmail.com>
Date: Sun, 21 Aug 2011 11:19:00 +0300
Subject: [carFl mem 52/65] Move coreboot specific variables to globals

Move partvendor_from_cbtable, lb_vendor, lb_part to globals structure.

Signed-off-by: Tadas Slotkus <devtadas@gmail.com>
---
 board_enable.c |    2 +-
 cbtable.c      |   21 +++++++++------------
 cli_classic.c  |    2 +-
 flash.h        |    2 ++
 flashrom.c     |    2 ++
 internal.c     |    2 +-
 layout.c       |   10 +++++-----
 programmer.h   |    2 --
 8 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/board_enable.c b/board_enable.c
index 6d88e77..cc39964 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -2136,7 +2136,7 @@ static const struct board_pciid_enable *board_match_coreboot_name(globals *g,
 	if (partmatch)
 		return partmatch;
 
-	if (!partvendor_from_cbtable) {
+	if (!g->partvendor_from_cbtable) {
 		/* Only warn if the mainboard type was not gathered from the
 		 * coreboot table. If it was, the coreboot implementor is
 		 * expected to fix flashrom, too.
diff --git a/cbtable.c b/cbtable.c
index 89abbfc..1cdc9f6 100644
--- a/cbtable.c
+++ b/cbtable.c
@@ -30,20 +30,17 @@
 #include "programmer.h"
 #include "coreboot_tables.h"
 
-char *lb_part = NULL, *lb_vendor = NULL;
-int partvendor_from_cbtable = 0;
-
 void lb_vendor_dev_from_string(globals *g, char *boardstring)
 {
 	char *tempstr2 = NULL;
 	strtok(boardstring, ":");
 	tempstr2 = strtok(NULL, ":");
 	if (tempstr2) {
-		lb_vendor = boardstring;
-		lb_part = tempstr2;
+		g->lb_vendor = boardstring;
+		g->lb_part = tempstr2;
 	} else {
-		lb_vendor = NULL;
-		lb_part = boardstring;
+		g->lb_vendor = NULL;
+		g->lb_part = boardstring;
 	}
 }
 
@@ -162,12 +159,12 @@ static void find_mainboard(globals *g, struct lb_record *ptr, unsigned long addr
 	snprintf(part, 255, "%.*s", max_size - rec->part_number_idx,
 		 rec->strings + rec->part_number_idx);
 
-	if (lb_part) {
-		msg_pdbg("Overwritten by command line, vendor ID: %s, part ID: %s.\n", lb_vendor, lb_part);
+	if (g->lb_part) {
+		msg_pdbg("Overwritten by command line, vendor ID: %s, part ID: %s.\n", g->lb_vendor, g->lb_part);
 	} else {
-		partvendor_from_cbtable = 1;
-		lb_part = strdup(part);
-		lb_vendor = strdup(vendor);
+		g->partvendor_from_cbtable = 1;
+		g->lb_part = strdup(part);
+		g->lb_vendor = strdup(vendor);
 	}
 }
 
diff --git a/cli_classic.c b/cli_classic.c
index 71b9469..a7abbd5 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -332,7 +332,7 @@ int cli_classic(globals *g, int argc, char *argv[])
 #endif
 
 #if CONFIG_INTERNAL == 1
-	if ((g->programmer != PROGRAMMER_INTERNAL) && (lb_part || lb_vendor)) {
+	if ((g->programmer != PROGRAMMER_INTERNAL) && (g->lb_part || g->lb_vendor)) {
 		fprintf(stderr, "Error: --mainboard requires the internal "
 				"programmer. Aborting.\n");
 		cli_classic_abort_usage();
diff --git a/flash.h b/flash.h
index 52698de..6c4a1d5 100644
--- a/flash.h
+++ b/flash.h
@@ -298,6 +298,8 @@ struct globals {
 	char *chip_to_probe;
 	/* Supported buses for the current programmer. */
 	enum chipbustype buses_supported;
+	char *lb_part, *lb_vendor;
+	int partvendor_from_cbtable;
 };
 void init_globals(globals *g);
 
diff --git a/flashrom.c b/flashrom.c
index 9e4ee80..3bfeaa9 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -53,6 +53,8 @@ void init_globals(globals *g)
 	g->undo_data_free_ptr = g->undo_data_buf;
 
 	g->chip_to_probe = NULL;
+	g->lb_part = NULL, g->lb_vendor = NULL;
+	g->partvendor_from_cbtable = 0;
 }
 
 static char *programmer_param = NULL;
diff --git a/internal.c b/internal.c
index 9f37d7b..03165a9 100644
--- a/internal.c
+++ b/internal.c
@@ -277,7 +277,7 @@ int internal_init(globals *g)
 	init_superio_ite(g);
 #endif
 
-	board_flash_enable(g, lb_vendor, lb_part);
+	board_flash_enable(g, g->lb_vendor, g->lb_part);
 
 	/* Even if chipset init returns an error code, we don't want to abort.
 	 * The error code might have been a warning only.
diff --git a/layout.c b/layout.c
index 6f25e69..b481f04 100644
--- a/layout.c
+++ b/layout.c
@@ -102,7 +102,7 @@ int show_id(globals *g, uint8_t *bios, int size, int force)
 	 * If lb_vendor is not set, the coreboot table was
 	 * not found. Nor was -m VENDOR:PART specified.
 	 */
-	if (!lb_vendor || !lb_part) {
+	if (!g->lb_vendor || !g->lb_part) {
 		msg_pinfo("Note: If the following flash access fails, "
 		       "try -m <vendor>:<mainboard>.\n");
 		return 0;
@@ -111,8 +111,8 @@ int show_id(globals *g, uint8_t *bios, int size, int force)
 	/* These comparisons are case insensitive to make things
 	 * a little less user^Werror prone. 
 	 */
-	if (!strcasecmp(mainboard_vendor, lb_vendor) &&
-	    !strcasecmp(mainboard_part, lb_part)) {
+	if (!strcasecmp(mainboard_vendor, g->lb_vendor) &&
+	    !strcasecmp(mainboard_part, g->lb_part)) {
 		msg_pdbg("This firmware image matches this mainboard.\n");
 	} else {
 		if (force_boardmismatch) {
@@ -126,8 +126,8 @@ int show_id(globals *g, uint8_t *bios, int size, int force)
 			       "that\nyou are using a correct "
 			       "image for this mainboard or override\nthe detected "
 			       "values with --mainboard <vendor>:<mainboard>.\n\n",
-			       mainboard_vendor, mainboard_part, lb_vendor,
-			       lb_part);
+			       mainboard_vendor, mainboard_part, g->lb_vendor,
+			       g->lb_part);
 			exit(1);
 		}
 	}
diff --git a/programmer.h b/programmer.h
index fd59d56..98502ad 100644
--- a/programmer.h
+++ b/programmer.h
@@ -207,8 +207,6 @@ void cleanup_cpu_msr(void);
 /* cbtable.c */
 void lb_vendor_dev_from_string(globals *g, char *boardstring);
 int coreboot_init(globals *g);
-extern char *lb_part, *lb_vendor;
-extern int partvendor_from_cbtable;
 
 /* dmi.c */
 extern int has_dmi_support;
-- 
1.7.6

