summaryrefslogtreecommitdiffstats
path: root/nicnatsemi.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2013-01-05 23:52:45 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2013-01-05 23:52:45 +0000
commita2faddf7d38e4651ce6654c62b668ab02b909b58 (patch)
tree1a13a2aa0134dbede16c017dd102efc81eb97ee0 /nicnatsemi.c
parentc6fa32d2b5c08d2fcc92fee2974a3fc02a3ca1f7 (diff)
downloadflashrom-a2faddf7d38e4651ce6654c62b668ab02b909b58.tar.gz
flashrom-a2faddf7d38e4651ce6654c62b668ab02b909b58.tar.bz2
flashrom-a2faddf7d38e4651ce6654c62b668ab02b909b58.zip
Decouple BAR reading from pci device init, handle errors gracefully
Pcidev_init() now returns struct pci_device * instead of a BAR stored in PCI config space. This allows for real error checking instead of having exit(1) everywhere in pcidev.c. Thanks to Niklas Söderlund for coming up with the original error handling patch which was slightly modified and folded into this patch. Move the declaration of struct pci_device in programmer.h before the first user. Corresponding to flashrom svn r1644. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
Diffstat (limited to 'nicnatsemi.c')
-rw-r--r--nicnatsemi.c15
1 files changed, 6 insertions, 9 deletions
diff --git a/nicnatsemi.c b/nicnatsemi.c
index 60d8f8777..d62a73f4c 100644
--- a/nicnatsemi.c
+++ b/nicnatsemi.c
@@ -52,22 +52,19 @@ static const struct par_programmer par_programmer_nicnatsemi = {
.chip_writen = fallback_chip_writen,
};
-static int nicnatsemi_shutdown(void *data)
-{
- pci_cleanup(pacc);
- return 0;
-}
-
int nicnatsemi_init(void)
{
+ struct pci_dev *dev = NULL;
+
if (rget_io_perms())
return 1;
- io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, nics_natsemi);
-
- if (register_shutdown(nicnatsemi_shutdown, NULL))
+ dev = pcidev_init(nics_natsemi, PCI_BASE_ADDRESS_0);
+ if (!dev)
return 1;
+ io_base_addr = pcidev_readbar(dev, PCI_BASE_ADDRESS_0);
+
/* The datasheet shows address lines MA0-MA16 in one place and MA0-MA15
* in another. My NIC has MA16 connected to A16 on the boot ROM socket
* so I'm assuming it is accessible. If not then next line wants to be