diff options
author | peter <peter@FreeBSD.org> | 1999-12-06 06:47:02 +0000 |
---|---|---|
committer | peter <peter@FreeBSD.org> | 1999-12-06 06:47:02 +0000 |
commit | 8bc1a5a150daf9df021bcc80b17669a09a64da12 (patch) | |
tree | 0995b685511314d0eed8b72abd1fa5221b71adf3 /sys/dev | |
parent | eed6e1031494591677c2aea98831b0d76faa920e (diff) | |
download | FreeBSD-src-8bc1a5a150daf9df021bcc80b17669a09a64da12.zip FreeBSD-src-8bc1a5a150daf9df021bcc80b17669a09a64da12.tar.gz |
Use bus_get_resource() instead of bus_get_resource_start() as the latter
returns "0" on failure, which is indistinguishable from (say) irq 0. This
should stop a couple of stray messages that turn up.
Also, if a BUS_SETUP_INTR() fails with INTR_TYPE_FAST, try falling back to
a normal interrupt. This might help pccard folks with a shared slot
interrupt. This whole thing needs to be revisited.
Diffstat (limited to 'sys/dev')
-rw-r--r-- | sys/dev/sio/sio.c | 41 |
1 files changed, 24 insertions, 17 deletions
diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index 4789c43..b9dac8c 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -610,8 +610,9 @@ sioprobe(dev) devclass_get_devices(sio_devclass, &devs, &count); for (i = 0; i < count; i++) { xdev = devs[i]; - xioport = bus_get_resource_start(xdev, SYS_RES_IOPORT, 0); - if (device_is_enabled(xdev) && xioport > 0) + if (device_is_enabled(xdev) && + bus_get_resource(xdev, SYS_RES_IOPORT, 0, &xioport, + NULL) == 0) outb(xioport + com_mcr, 0); } free(devs, M_TEMP); @@ -643,15 +644,17 @@ sioprobe(dev) device_get_unit(dev), COM_MPMASTER(flags)); idev = dev; } - xiobase = bus_get_resource_start(idev, SYS_RES_IOPORT, 0); - if (xiobase > 0) { - xirq = bus_get_resource_start(idev, SYS_RES_IRQ, 0); - outb(xiobase + com_scr, xirq >= 0 ? 0x80 : 0); + if (bus_get_resource(idev, SYS_RES_IOPORT, 0, &xiobase, + NULL) == 0) { + if (bus_get_resource(idev, SYS_RES_IRQ, 0, NULL, NULL)) + outb(xiobase + com_scr, 0x80); /* no irq */ + else + outb(xiobase + com_scr, 0); } mcr_image = 0; } #endif /* COM_MULTIPORT */ - if (bus_get_resource_start(idev, SYS_RES_IRQ, 0) <= 0) + if (bus_get_resource(idev, SYS_RES_IRQ, 0, NULL, NULL) != 0) mcr_image = 0; bzero(failures, sizeof failures); @@ -803,8 +806,8 @@ sioprobe(dev) enable_intr(); irqs = irqmap[1] & ~irqmap[0]; - xirq = bus_get_resource_start(idev, SYS_RES_IRQ, 0); - if (xirq >= 0 && ((1 << xirq) & irqs) == 0) + if (bus_get_resource(idev, SYS_RES_IRQ, 0, &xirq, NULL) == 0 && + ((1 << xirq) & irqs) == 0) printf( "sio%d: configured irq %d not in bitmap of probed irqs %#x\n", device_get_unit(dev), xirq, irqs); @@ -913,7 +916,6 @@ sioattach(dev) Port_t *espp; #endif Port_t iobase; - int irq; int unit; void *ih; u_int flags; @@ -928,7 +930,6 @@ sioattach(dev) return ENXIO; iobase = rman_get_start(port); - irq = bus_get_resource_start(dev, SYS_RES_IRQ, 0); unit = device_get_unit(dev); com = device_get_softc(dev); flags = device_get_flags(dev); @@ -953,7 +954,7 @@ sioattach(dev) com->cfcr_image = CFCR_8BITS; com->dtr_wait = 3 * hz; com->loses_outints = COM_LOSESOUTINTS(flags) != 0; - com->no_irq = irq < 0; + com->no_irq = bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL); com->tx_fifo_size = 1; com->obufs[0].l_head = com->obuf1; com->obufs[1].l_head = com->obuf2; @@ -1098,7 +1099,6 @@ determined_type: ; #ifdef COM_MULTIPORT if (COM_ISMULTIPORT(flags)) { device_t masterdev; - int irq; com->multiport = TRUE; printf(" (multiport"); @@ -1107,8 +1107,8 @@ determined_type: ; printf(")"); masterdev = devclass_get_device(sio_devclass, COM_MPMASTER(flags)); - irq = bus_get_resource_start(masterdev, SYS_RES_IRQ, 0); - com->no_irq = irq < 0; + com->no_irq = bus_get_resource(masterdev, SYS_RES_IRQ, 0, NULL, + NULL); } #endif /* COM_MULTIPORT */ if (unit == comconsole) @@ -1142,8 +1142,15 @@ determined_type: ; RF_ACTIVE); if (com->irqres) { ret = BUS_SETUP_INTR(device_get_parent(dev), dev, com->irqres, - INTR_TYPE_TTY | INTR_TYPE_FAST, - siointr, com, &ih); + INTR_TYPE_TTY | INTR_TYPE_FAST, + siointr, com, &ih); + if (ret) { + ret = BUS_SETUP_INTR(device_get_parent(dev), dev, + com->irqres, INTR_TYPE_TTY, + siointr, com, &ih); + if (ret == 0) + device_printf(dev, "unable to activate interrupt in fast mode - using normal mode"); + } if (ret) device_printf(dev, "could not activate interrupt\n"); } |