diff options
author | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2013-01-05 23:52:45 +0000 |
---|---|---|
committer | Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> | 2013-01-05 23:52:45 +0000 |
commit | b1c04297f1f115cdb904644ae48f1234a3cbc16e (patch) | |
tree | 1a13a2aa0134dbede16c017dd102efc81eb97ee0 /nicrealtek.c | |
parent | e50ae6b37e1e49359254ac64bc6052744128f569 (diff) | |
download | flashrom-b1c04297f1f115cdb904644ae48f1234a3cbc16e.zip flashrom-b1c04297f1f115cdb904644ae48f1234a3cbc16e.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.
Binary file (standard input) matches
Corresponding to flashrom svn r1644.
Diffstat (limited to 'nicrealtek.c')
-rw-r--r-- | nicrealtek.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/nicrealtek.c b/nicrealtek.c index 8349b42..fb8e9e1 100644 --- a/nicrealtek.c +++ b/nicrealtek.c @@ -59,16 +59,19 @@ static int nicrealtek_shutdown(void *data) int nicrealtek_init(void) { + struct pci_dev *dev = NULL; + if (rget_io_perms()) return 1; - /* No need to check for errors, pcidev_init() will not return in case of errors. */ - io_base_addr = pcidev_init(PCI_BASE_ADDRESS_0, nics_realtek); - if (register_shutdown(nicrealtek_shutdown, NULL)) + dev = pcidev_init(nics_realtek, PCI_BASE_ADDRESS_0); + if (!dev) return 1; + io_base_addr = pcidev_readbar(dev, PCI_BASE_ADDRESS_0); + /* Beware, this ignores the vendor ID! */ - switch (pcidev_dev->device_id) { + switch (dev->device_id) { case 0x8139: /* RTL8139 */ case 0x1211: /* SMC 1211TX */ default: @@ -81,6 +84,9 @@ int nicrealtek_init(void) break; } + if (register_shutdown(nicrealtek_shutdown, NULL)) + return 1; + register_par_programmer(&par_programmer_nicrealtek, BUS_PARALLEL); return 0; |