summaryrefslogtreecommitdiff
path: root/satamv.c
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2013-01-05 23:52:45 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2013-01-05 23:52:45 +0000
commit1258228f6cee785ba4426d223a356b3ef7439481 (patch)
tree1a13a2aa0134dbede16c017dd102efc81eb97ee0 /satamv.c
parent4f76e2f91d69dae46c42155d65b80e1d0f2bbdfc (diff)
downloadflashrom-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 'satamv.c')
-rw-r--r--satamv.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/satamv.c b/satamv.c
index 46a0e2d..c3f27e7 100644
--- a/satamv.c
+++ b/satamv.c
@@ -81,6 +81,7 @@ static int satamv_shutdown(void *data)
*/
int satamv_init(void)
{
+ struct pci_dev *dev = NULL;
uintptr_t addr;
uint32_t tmp;
@@ -88,11 +89,11 @@ int satamv_init(void)
return 1;
/* BAR0 has all internal registers memory mapped. */
- /* No need to check for errors, pcidev_init() will not return in case
- * of errors.
- */
- addr = pcidev_init(PCI_BASE_ADDRESS_0, satas_mv);
+ dev = pcidev_init(satas_mv, PCI_BASE_ADDRESS_0);
+ if (!dev)
+ return 1;
+ addr = pcidev_readbar(dev, PCI_BASE_ADDRESS_0);
mv_bar = physmap("Marvell 88SX7042 registers", addr, 0x20000);
if (mv_bar == ERROR_PTR)
return 1;
@@ -143,8 +144,7 @@ int satamv_init(void)
pci_rmmio_writel(tmp, mv_bar + GPIO_PORT_CONTROL);
/* Get I/O BAR location. */
- tmp = pci_read_long(pcidev_dev, PCI_BASE_ADDRESS_2) &
- PCI_BASE_ADDRESS_IO_MASK;
+ tmp = pcidev_readbar(dev, PCI_BASE_ADDRESS_2);
/* Truncate to reachable range.
* FIXME: Check if the I/O BAR is actually reachable.
* This is an arch specific check.