>From 535954736b9761d8b8e538879a45963cab640c17 Mon Sep 17 00:00:00 2001
From: Tadas Slotkus <devtadas@gmail.com>
Date: Wed, 17 Aug 2011 16:30:32 +0300
Subject: [carFl mem 20/21] Move more globals to our structure

is_laptop;
laptop_ok;
force_boardenable;
force_boardmismatch;

Signed-off-by: Tadas Slotkus <devtadas@gmail.com>
---
 board_enable.c |    2 +-
 dmi.c          |    6 +++---
 flash.h        |    5 +++++
 flashrom.c     |    4 ++++
 internal.c     |   13 ++++---------
 layout.c       |    2 +-
 programmer.h   |    4 ----
 7 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/board_enable.c b/board_enable.c
index 708f5d4..f9c3339 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -2215,7 +2215,7 @@ static int unsafe_board_handler(const struct board_pciid_enable *board)
 	if (board->status == OK)
 		return 0;
 
-	if (!force_boardenable) {
+	if (!g->force_boardenable) {
 		msg_pinfo("WARNING: Your mainboard is %s %s, but the mainboard-specific\n"
 			  "code has not been tested, and thus will not be executed by default.\n"
 			  "Depending on your hardware environment, erasing, writing or even probing\n"
diff --git a/dmi.c b/dmi.c
index 0503af1..bcd2c3b 100644
--- a/dmi.c
+++ b/dmi.c
@@ -169,15 +169,15 @@ void dmi_init(void)
 	if (chassis_type == NULL)
 		return;
 
-	is_laptop = 2;
+	g->is_laptop = 2;
 	for (i = 0; i < ARRAY_SIZE(dmi_chassis_types); i++) {
 		if (strcasecmp(chassis_type, dmi_chassis_types[i].name) == 0) {
-			is_laptop = dmi_chassis_types[i].is_laptop;
+			g->is_laptop = dmi_chassis_types[i].is_laptop;
 			break;
 		}
 	}
 
-	switch (is_laptop) {
+	switch (g->is_laptop) {
 	case 1:
 		msg_pdbg("Laptop detected via DMI.\n");
 		break;
diff --git a/flash.h b/flash.h
index 533dd1d..cb0a440 100644
--- a/flash.h
+++ b/flash.h
@@ -318,6 +318,11 @@ struct globals {
 	struct superio superios[SUPERIO_MAX_COUNT];
 	int superio_count;
 
+	int is_laptop;
+	int laptop_ok;
+	int force_boardenable;
+	int force_boardmismatch;
+
 	/*
 	 * Programmers supporting multiple buses can have differing size limits on
 	 * each bus. Store the limits for each bus in a common struct.
diff --git a/flashrom.c b/flashrom.c
index c351b3d..21711f2 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -104,6 +104,10 @@ static void init_globals(void)
 
 	g.lb_part = NULL, g.lb_vendor = NULL;
 	g.partvendor_from_cbtable = 0;
+	g.is_laptop = 0;
+	g.laptop_ok = 0;
+	g.force_boardenable = 0;
+	g.force_boardmismatch = 0;
 	g.has_dmi_support = 0;
 	g.superio_count = 0;
 	g.ichspi_bbar = 0;
diff --git a/internal.c b/internal.c
index 883f515..396de7a 100644
--- a/internal.c
+++ b/internal.c
@@ -102,8 +102,6 @@ struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
 #endif
 
 #if CONFIG_INTERNAL == 1
-int force_boardenable = 0;
-int force_boardmismatch = 0;
 
 #if defined(__i386__) || defined(__x86_64__)
 void probe_superio(void)
@@ -126,9 +124,6 @@ int register_superio(struct superio s)
 
 #endif
 
-int is_laptop = 0;
-int laptop_ok = 0;
-
 static int internal_shutdown(void *data)
 {
 	release_io_perms();
@@ -145,7 +140,7 @@ int internal_init(void)
 
 	arg = extract_programmer_param("boardenable");
 	if (arg && !strcmp(arg,"force")) {
-		force_boardenable = 1;
+		g->force_boardenable = 1;
 	} else if (arg && !strlen(arg)) {
 		msg_perr("Missing argument for boardenable.\n");
 		free(arg);
@@ -159,7 +154,7 @@ int internal_init(void)
 
 	arg = extract_programmer_param("boardmismatch");
 	if (arg && !strcmp(arg,"force")) {
-		force_boardmismatch = 1;
+		g->force_boardmismatch = 1;
 	} else if (arg && !strlen(arg)) {
 		msg_perr("Missing argument for boardmismatch.\n");
 		free(arg);
@@ -231,9 +226,9 @@ int internal_init(void)
 	board_handle_before_laptop();
 
 	/* Warn if a non-whitelisted laptop is detected. */
-	if (is_laptop && !laptop_ok) {
+	if (g->is_laptop && !g->laptop_ok) {
 		msg_perr("========================================================================\n");
-		if (is_laptop == 1) {
+		if (g->is_laptop == 1) {
 			msg_perr("WARNING! You seem to be running flashrom on an unsupported laptop.\n");
 		} else {
 			msg_perr("WARNING! You may be running flashrom on an unsupported laptop. We could\n"
diff --git a/layout.c b/layout.c
index a91296c..4dcf072 100644
--- a/layout.c
+++ b/layout.c
@@ -122,7 +122,7 @@ int show_id(uint8_t *bios, int size, int force)
 	    !strcasecmp(mainboard_part, g->lb_part)) {
 		msg_pdbg("This firmware image matches this mainboard.\n");
 	} else {
-		if (force_boardmismatch) {
+		if (g->force_boardmismatch) {
 			msg_pinfo("WARNING: This firmware image does not "
 			       "seem to fit to this machine - forcing it.\n");
 		} else {
diff --git a/programmer.h b/programmer.h
index a20e378..e94c13f 100644
--- a/programmer.h
+++ b/programmer.h
@@ -226,10 +226,6 @@ struct pci_dev *pci_card_find(uint16_t vendor, uint16_t device,
 void get_io_perms(void);
 void release_io_perms(void);
 #if CONFIG_INTERNAL == 1
-extern int is_laptop;
-extern int laptop_ok;
-extern int force_boardenable;
-extern int force_boardmismatch;
 void probe_superio(void);
 int register_superio(struct superio s);
 int internal_init(void);
-- 
1.7.6

