>From 8c1ea70df04dc06765df461242ddc786a9f6641e Mon Sep 17 00:00:00 2001
From: Tadas Slotkus <devtadas@gmail.com>
Date: Sun, 21 Aug 2011 15:43:28 +0300
Subject: [carFl mem 57/65] Move pci access variable to globals

Move pacc to globals.

Signed-off-by: Tadas Slotkus <devtadas@gmail.com>
---
 board_enable.c |    6 +++---
 flash.h        |    1 +
 internal.c     |   14 +++++++-------
 pcidev.c       |    2 --
 programmer.h   |    1 -
 5 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/board_enable.c b/board_enable.c
index 7241675..d1e6a21 100644
--- a/board_enable.c
+++ b/board_enable.c
@@ -882,13 +882,13 @@ static int nvidia_mcp_gpio_set(globals *g, int gpio, int raise)
 		}
 
 #if PCI_LIB_VERSION >= 0x020200
-		dev = pci_get_dev(pacc, dev->domain, dev->bus, dev->dev, 1);
+		dev = pci_get_dev(g->pacc, dev->domain, dev->bus, dev->dev, 1);
 #else
 		/* pciutils/libpci before version 2.2 is too old to support
 		 * PCI domains. Such old machines usually don't have domains
 		 * besides domain 0, so this is not a problem.
 		 */
-		dev = pci_get_dev(pacc, dev->bus, dev->dev, 1);
+		dev = pci_get_dev(g->pacc, dev->bus, dev->dev, 1);
 #endif
 		if (!dev) {
 			msg_perr("MCP SMBus controller could not be found\n");
@@ -1313,7 +1313,7 @@ static int intel_ich_gpio_set(globals *g, int gpio, int raise)
 	int i, allowed;
 
 	/* First, look for a known LPC bridge */
-	for (dev = pacc->devices; dev; dev = dev->next) {
+	for (dev = g->pacc->devices; dev; dev = dev->next) {
 		uint16_t device_class;
 		/* libpci before version 2.2.4 does not store class info. */
 		device_class = pci_read_word(dev, PCI_CLASS_DEVICE);
diff --git a/flash.h b/flash.h
index e22b7f3..d226551 100644
--- a/flash.h
+++ b/flash.h
@@ -307,6 +307,7 @@ struct globals {
 
 	int superio_count;
 	uint32_t ichspi_bbar;
+	struct pci_access *pacc;
 };
 void init_globals(globals *g);
 
diff --git a/internal.c b/internal.c
index c29bf41..22c77eb 100644
--- a/internal.c
+++ b/internal.c
@@ -28,7 +28,7 @@ struct pci_dev *pci_dev_find_filter(globals *g, struct pci_filter filter)
 {
 	struct pci_dev *temp;
 
-	for (temp = pacc->devices; temp; temp = temp->next)
+	for (temp = g->pacc->devices; temp; temp = temp->next)
 		if (pci_filter_match(&filter, temp))
 			return temp;
 
@@ -44,7 +44,7 @@ struct pci_dev *pci_dev_find_vendorclass(globals *g, uint16_t vendor, uint16_t d
 	pci_filter_init(NULL, &filter);
 	filter.vendor = vendor;
 
-	for (temp = pacc->devices; temp; temp = temp->next)
+	for (temp = g->pacc->devices; temp; temp = temp->next)
 		if (pci_filter_match(&filter, temp)) {
 			/* Read PCI class */
 			tmp2 = pci_read_word(temp, 0x0a);
@@ -64,7 +64,7 @@ struct pci_dev *pci_dev_find(globals *g, uint16_t vendor, uint16_t device)
 	filter.vendor = vendor;
 	filter.device = device;
 
-	for (temp = pacc->devices; temp; temp = temp->next)
+	for (temp = g->pacc->devices; temp; temp = temp->next)
 		if (pci_filter_match(&filter, temp))
 			return temp;
 
@@ -81,7 +81,7 @@ struct pci_dev *pci_card_find(globals *g, uint16_t vendor, uint16_t device,
 	filter.vendor = vendor;
 	filter.device = device;
 
-	for (temp = pacc->devices; temp; temp = temp->next)
+	for (temp = g->pacc->devices; temp; temp = temp->next)
 		if (pci_filter_match(&filter, temp)) {
 			if ((card_vendor ==
 			     pci_read_word(temp, PCI_SUBSYSTEM_VENDOR_ID))
@@ -187,10 +187,10 @@ int internal_init(globals *g)
 	g->buses_supported = BUS_NONSPI;
 
 	/* Initialize PCI access for flash enables */
-	pacc = pci_alloc();	/* Get the pci_access structure */
+	g->pacc = pci_alloc();	/* Get the pci_access structure */
 	/* Set all options you want -- here we stick with the defaults */
-	pci_init(pacc);		/* Initialize the PCI library */
-	pci_scan_bus(pacc);	/* We want to get the list of devices */
+	pci_init(g->pacc);		/* Initialize the PCI library */
+	pci_scan_bus(g->pacc);	/* We want to get the list of devices */
 
 	if (processor_flash_enable(g)) {
 		msg_perr("Processor detection/init failed.\n"
diff --git a/pcidev.c b/pcidev.c
index fd8b78f..7af15e3 100644
--- a/pcidev.c
+++ b/pcidev.c
@@ -24,8 +24,6 @@
 #include "flash.h"
 #include "programmer.h"
 
-struct pci_access *pacc;
-
 enum pci_bartype {
 	TYPE_MEMBAR,
 	TYPE_IOBAR,
diff --git a/programmer.h b/programmer.h
index fae0154..1b7b750 100644
--- a/programmer.h
+++ b/programmer.h
@@ -153,7 +153,6 @@ void internal_delay(int usecs);
 
 #if NEED_PCI == 1
 /* pcidev.c */
-extern struct pci_access *pacc;
 struct pcidev_status {
 	uint16_t vendor_id;
 	uint16_t device_id;
-- 
1.7.6

