diff options
author | hailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2013-01-05 23:52:45 +0000 |
---|---|---|
committer | hailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1> | 2013-01-05 23:52:45 +0000 |
commit | 1258228f6cee785ba4426d223a356b3ef7439481 (patch) | |
tree | 1a13a2aa0134dbede16c017dd102efc81eb97ee0 /ogp_spi.c | |
parent | 4f76e2f91d69dae46c42155d65b80e1d0f2bbdfc (diff) | |
download | flashrom-1258228f6cee785ba4426d223a356b3ef7439481.tar.gz |
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.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Stefan Tauner <stefan.tauner@student.tuwien.ac.at>
git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1644 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
Diffstat (limited to 'ogp_spi.c')
-rw-r--r-- | ogp_spi.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -105,6 +105,7 @@ static int ogp_spi_shutdown(void *data) int ogp_spi_init(void) { + struct pci_dev *dev = NULL; char *type; type = extract_programmer_param("rom"); @@ -131,8 +132,11 @@ int ogp_spi_init(void) if (rget_io_perms()) return 1; - io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, ogp_spi); + dev = pcidev_init(ogp_spi, PCI_BASE_ADDRESS_0); + if (!dev) + return 1; + io_base_addr = pcidev_readbar(dev, PCI_BASE_ADDRESS_0); ogp_spibar = physmap("OGP registers", io_base_addr, 4096); if (register_shutdown(ogp_spi_shutdown, NULL)) |