Unify PCI init and let pcidev clean itself up

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 and adds
an additional safety by checking for an already existing PCI context.

We got a nice shutdown function registration infrastructure, but did not use it
very wisely. Instead we added shutdown functions to a myriad of programmers
unnecessarily. In this patch we get rid of those that do only call pci_cleanup(pacc)
by adding a shutdown function the pcidev.c itself that gets registered by
pcidev_init().

Corresponding to flashrom svn r1642.

Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
diff --git a/satamv.c b/satamv.c
index c0c1ffa..46a0e2d 100644
--- a/satamv.c
+++ b/satamv.c
@@ -60,7 +60,6 @@
 static int satamv_shutdown(void *data)
 {
 	physunmap(mv_bar, 0x20000);
-	pci_cleanup(pacc);
 	return 0;
 }
 
@@ -96,7 +95,7 @@
 
 	mv_bar = physmap("Marvell 88SX7042 registers", addr, 0x20000);
 	if (mv_bar == ERROR_PTR)
-		goto error_out;
+		return 1;
 
 	if (register_shutdown(satamv_shutdown, NULL))
 		return 1;
@@ -159,10 +158,6 @@
 	register_par_programmer(&par_programmer_satamv, BUS_PARALLEL);
 
 	return 0;
-
-error_out:
-	pci_cleanup(pacc);
-	return 1;
 }
 
 /* BAR2 (MEM) can map NVRAM and flash. We set it to flash in the init function.