diff options
author | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-09-20 16:35:18 +0000 |
---|---|---|
committer | Matthieu Herrb <matthieu@cvs.openbsd.org> | 2008-09-20 16:35:18 +0000 |
commit | 5db75880dfda7b70a4518509c93d8e5a3c643aa6 (patch) | |
tree | f6f0cdfb8379e2c95e364c2a386c166f859a40bf | |
parent | f75e37ea8821e2f1938245f8bd8f2265ede7d7db (diff) |
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@.
-rw-r--r-- | lib/libpciaccess/src/openbsd_pci.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/lib/libpciaccess/src/openbsd_pci.c b/lib/libpciaccess/src/openbsd_pci.c index 5c06b4743..7bb20d6e5 100644 --- a/lib/libpciaccess/src/openbsd_pci.c +++ b/lib/libpciaccess/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; |