summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2006-10-04 19:27:45 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2006-10-04 19:27:45 +0000
commitb5691837278ca90532d19f502215508cffb6df78 (patch)
tree314d6ecb5a41af9b4ee80ebb048d1c55a1734f81 /sys/dev
parent99b61f0144b34d75a7da4b2f0210406d501da213 (diff)
Do not assume that the pci(4) unit number matches the actual PCI bus number.
Fixes cases where X would get really confused when they didn't match. ok drahn@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/pci/pci.c18
1 files changed, 9 insertions, 9 deletions
diff --git a/sys/dev/pci/pci.c b/sys/dev/pci/pci.c
index e68226b8cbd..8483da534db 100644
--- a/sys/dev/pci/pci.c
+++ b/sys/dev/pci/pci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci.c,v 1.46 2006/07/04 18:07:29 kettenis Exp $ */
+/* $OpenBSD: pci.c,v 1.47 2006/10/04 19:27:44 kettenis Exp $ */
/* $NetBSD: pci.c,v 1.31 1997/06/06 23:48:04 thorpej Exp $ */
/*
@@ -518,9 +518,9 @@ int
pciioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
{
struct pci_io *io;
- int error;
+ int i, error;
pcitag_t tag;
- struct pci_softc *pci;
+ struct pci_softc *pci = NULL;
pci_chipset_tag_t pc;
io = (struct pci_io *)data;
@@ -530,12 +530,12 @@ pciioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
PCIDEBUG((" bus %d dev %d func %d reg %x\n", io->pi_sel.pc_bus,
io->pi_sel.pc_dev, io->pi_sel.pc_func, io->pi_reg));
- if (io->pi_sel.pc_bus >= pci_cd.cd_ndevs) {
- error = ENXIO;
- goto done;
+ for (i = 0; i < pci_cd.cd_ndevs; i++) {
+ pci = pci_cd.cd_devs[i];
+ if (pci != NULL && pci->sc_bus == io->pi_sel.pc_bus)
+ break;
}
- pci = pci_cd.cd_devs[io->pi_sel.pc_bus];
- if (pci != NULL) {
+ if (pci != NULL && pci->sc_bus == io->pi_sel.pc_bus) {
pc = pci->sc_pc;
} else {
error = ENXIO;
@@ -549,7 +549,7 @@ pciioctl(dev_t dev, u_long cmd, caddr_t data, int flag, struct proc *p)
goto done;
}
- tag = pci_make_tag(pc, pci->sc_bus, io->pi_sel.pc_dev,
+ tag = pci_make_tag(pc, io->pi_sel.pc_bus, io->pi_sel.pc_dev,
io->pi_sel.pc_func);
switch(cmd) {