summaryrefslogtreecommitdiff
path: root/satasii.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 /satasii.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 'satasii.c')
-rw-r--r--satasii.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/satasii.c b/satasii.c
index ec65bd0..72e35e5 100644
--- a/satasii.c
+++ b/satasii.c
@@ -76,21 +76,24 @@ static uint32_t satasii_wait_done(void)
int satasii_init(void)
{
+ struct pci_dev *dev = NULL;
uint32_t addr;
uint16_t reg_offset;
if (rget_io_perms())
return 1;
- pcidev_init(PCI_BASE_ADDRESS_0, satas_sii);
+ dev = pcidev_init(satas_sii, PCI_BASE_ADDRESS_0);
+ if (!dev)
+ return 1;
- id = pcidev_dev->device_id;
+ id = dev->device_id;
if ((id == 0x3132) || (id == 0x3124)) {
- addr = pci_read_long(pcidev_dev, PCI_BASE_ADDRESS_0) & ~0x07;
+ addr = pcidev_readbar(dev, PCI_BASE_ADDRESS_0);
reg_offset = 0x70;
} else {
- addr = pci_read_long(pcidev_dev, PCI_BASE_ADDRESS_5) & ~0x07;
+ addr = pcidev_readbar(dev, PCI_BASE_ADDRESS_5);
reg_offset = 0x50;
}