aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Mares <mj@ucw.cz>2020-05-31 12:22:53 +0200
committerMartin Mares <mj@ucw.cz>2020-05-31 12:23:39 +0200
commit5ea0707b184af73880ad5dd99e8bab4e3480a43f (patch)
tree915ee590c2dbe4199bc7ca8d18389acd01e236e7
parent292a2fc93ad1edb9bd648d166782ed8b0fa5a9f6 (diff)
downloadpciutils-5ea0707b184af73880ad5dd99e8bab4e3480a43f.tar.gz
Hurd: Simplification continues
-rw-r--r--lib/hurd.c28
1 files changed, 7 insertions, 21 deletions
diff --git a/lib/hurd.c b/lib/hurd.c
index a184bc5..873bb78 100644
--- a/lib/hurd.c
+++ b/lib/hurd.c
@@ -102,6 +102,9 @@ device_port_lookup(struct pci_dev *d)
FILE_CONFIG_NAME);
device_port = file_name_lookup(server, 0, 0);
+ if (device_port == MACH_PORT_NULL)
+ a->error("Cannot find the PCI arbiter");
+
*((mach_port_t *) d->aux) = device_port;
return device_port;
}
@@ -189,15 +192,6 @@ enum_devices(const char *parent, struct pci_access *a, int domain, int bus,
d->dev = dev;
d->func = func;
- /* Get the arbiter port */
- if (device_port_lookup(d) == MACH_PORT_NULL)
- {
- if (closedir(dir) < 0)
- a->warning("Cannot close directory: %s (%s)", parent,
- strerror(errno));
- a->error("Cannot find the PCI arbiter");
- }
-
pci_link_dev(a, d);
vd = pci_read_long(d, PCI_VENDOR_ID);
@@ -232,15 +226,11 @@ hurd_read(struct pci_dev *d, int pos, byte * buf, int len)
int err;
size_t nread;
char *data;
- mach_port_t device_port;
+ mach_port_t device_port = device_port_lookup(d);
if (len > 4)
return pci_generic_block_read(d, pos, buf, nread);
- device_port = device_port_lookup(d);
- if (device_port == MACH_PORT_NULL)
- d->access->error("Cannot find the PCI arbiter");
-
data = (char *) buf;
nread = len;
err = pci_conf_read(device_port, pos, &data, &nread, len);
@@ -270,15 +260,11 @@ hurd_write(struct pci_dev *d, int pos, byte * buf, int len)
{
int err;
size_t nwrote;
- mach_port_t device_port;
+ mach_port_t device_port = device_port_lookup(d);
if (len > 4)
return pci_generic_block_write(d, pos, buf, len);
- device_port = device_port_lookup(d);
- if (device_port == MACH_PORT_NULL)
- d->access->error("Cannot find the PCI arbiter");
-
nwrote = len;
err = pci_conf_write(device_port, pos, (char *) buf, len, &nwrote);
@@ -290,7 +276,7 @@ hurd_write(struct pci_dev *d, int pos, byte * buf, int len)
static void
hurd_fill_regions(struct pci_dev *d)
{
- mach_port_t device_port = *((mach_port_t *) d->aux);
+ mach_port_t device_port = device_port_lookup(d);
struct pci_bar regions[6];
char *buf = (char *) &regions;
size_t size = sizeof(regions);
@@ -330,7 +316,7 @@ static void
hurd_fill_rom(struct pci_dev *d)
{
struct pci_xrom_bar rom;
- mach_port_t device_port = *((mach_port_t *) d->aux);
+ mach_port_t device_port = device_port_lookup(d);
char *buf = (char *) &rom;
size_t size = sizeof(rom);