Previously the internal programmer used its own code to initialize pcilib. This patch extracts the common code from the internal programmer and pcidev_init() into pcidev_init_common().
This fixes the non-existent PCI cleanup of the internal programmer.
Signed-off-by: Stefan Tauner stefan.tauner@student.tuwien.ac.at --- internal.c | 6 ++---- pcidev.c | 15 +++++++++++---- programmer.h | 1 + 3 files changed, 14 insertions(+), 8 deletions(-)
diff --git a/internal.c b/internal.c index eda4d59..9b34715 100644 --- a/internal.c +++ b/internal.c @@ -245,10 +245,8 @@ int internal_init(void) internal_buses_supported = BUS_NONSPI;
/* Initialize PCI access for flash enables */ - 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 */ + if(pci_init_common() != 0) + return 1;
if (processor_flash_enable()) { msg_perr("Processor detection/init failed.\n" diff --git a/pcidev.c b/pcidev.c index 37bcc22..7f1f243 100644 --- a/pcidev.c +++ b/pcidev.c @@ -162,6 +162,16 @@ static int pcidev_shutdown(void *data) return 0; }
+int pcidev_init_common(void) +{ + pacc = pci_alloc(); /* Get the pci_access structure */ + pci_init(pacc); /* Initialize the PCI library */ + if (register_shutdown(pcidev_shutdown, NULL)) + return 1; + pci_scan_bus(pacc); /* We want to get the list of devices */ + return 0; +} + uintptr_t pcidev_init(int bar, const struct dev_entry *devs) { struct pci_dev *dev; @@ -172,11 +182,8 @@ uintptr_t pcidev_init(int bar, const struct dev_entry *devs) int i; uintptr_t addr = 0, curaddr = 0;
- pacc = pci_alloc(); /* Get the pci_access structure */ - pci_init(pacc); /* Initialize the PCI library */ - if (register_shutdown(pcidev_shutdown, NULL)) + if(pcidev_init_common() != 0) return 1; - pci_scan_bus(pacc); /* We want to get the list of devices */ pci_filter_init(pacc, &filter);
/* Filter by bb:dd.f (if supplied by the user). */ diff --git a/programmer.h b/programmer.h index 8de42bc..7703ec1 100644 --- a/programmer.h +++ b/programmer.h @@ -238,6 +238,7 @@ void internal_delay(int usecs); extern uint32_t io_base_addr; extern struct pci_access *pacc; extern struct pci_dev *pcidev_dev; +int pcidev_init_common(void); uintptr_t pcidev_readbar(struct pci_dev *dev, int bar); uintptr_t pcidev_init(int bar, const struct dev_entry *devs); /* rpci_write_* are reversible writes. The original PCI config space register