summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMatthieu Herrb <matthieu.herrb@laas.fr>2008-09-20 18:28:59 +0200
committerMatthieu Herrb <matthieu.herrb@laas.fr>2008-09-20 18:28:59 +0200
commit79ed41882fd721a15c8b0bea7efeb98864d85dfb (patch)
treedc6440a06027077e68f17567b33682f48ad4e288 /src
parent45015ab30b36bdaefd3f3aeab73d287023928826 (diff)
downloadlibpciaccess-79ed41882fd721a15c8b0bea7efeb98864d85dfb.tar.gz
libpciaccess-79ed41882fd721a15c8b0bea7efeb98864d85dfb.tar.bz2
libpciaccess-79ed41882fd721a15c8b0bea7efeb98864d85dfb.zip
OpenBSD: allow 2 successives calls to pci_system_init().
And fix pci_system_cleanup() to make it possible to call pci_system_init() again. ok kettenis at openbsd.
Diffstat (limited to 'src')
-rw-r--r--src/openbsd_pci.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/openbsd_pci.c b/src/openbsd_pci.c
index 5c06b47..7bb20d6 100644
--- a/src/openbsd_pci.c
+++ b/src/openbsd_pci.c
@@ -33,7 +33,7 @@
#include "pciaccess.h"
#include "pciaccess_private.h"
-static int pcifd;
+static int pcifd = -1;
static int aperturefd = -1;
static int
@@ -216,6 +216,8 @@ pci_system_openbsd_destroy(void)
{
close(aperturefd);
close(pcifd);
+ aperturefd = -1;
+ pcifd = -1;
free(pci_sys);
pci_sys = NULL;
}
@@ -318,6 +320,9 @@ pci_system_openbsd_create(void)
int bus, dev, func, ndevs, nfuncs;
uint32_t reg;
+ if (pcifd != -1)
+ return 0;
+
pcifd = open("/dev/pci", O_RDWR);
if (pcifd == -1)
return ENXIO;