From 54489bb7493e06d358070fdbac16a8b28853e4c9 Mon Sep 17 00:00:00 2001 From: bde Date: Tue, 15 Feb 2000 17:29:09 +0000 Subject: Fixed regressions in rev.1.274: 1) Non-AST4 multiport cards were broken by bypassing the code that changes `idev' to the multiport master device. 2) AST4 multiport cards apparently were broken by inverting the test for the master device having an irq. 3) Error handling for nonexistent master devices was broken by removing a check for a null pointer. 4) `int' error codes returned by bus_get_resource() were assigned directly to the boolean variable com->no_irq. Probably harmless, since the boolean is implemented as a u_char. Submitted by: part 1) by Chris Radek part 2) by yokota Approved by: jkh --- sys/dev/sio/sio.c | 26 +++++++++++++++----------- sys/isa/sio.c | 26 +++++++++++++++----------- 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/sys/dev/sio/sio.c b/sys/dev/sio/sio.c index a409a55..0876620 100644 --- a/sys/dev/sio/sio.c +++ b/sys/dev/sio/sio.c @@ -692,7 +692,7 @@ sioprobe(dev) idev = dev; mcr_image = MCR_IENABLE; #ifdef COM_MULTIPORT - if (COM_ISMULTIPORT(flags) && !COM_NOTAST4(flags)) { + if (COM_ISMULTIPORT(flags)) { Port_t xiobase; u_long io; @@ -702,14 +702,18 @@ sioprobe(dev) device_get_unit(dev), COM_MPMASTER(flags)); idev = dev; } - if (bus_get_resource(idev, SYS_RES_IOPORT, 0, &io, NULL) == 0) { - xiobase = io; - if (bus_get_resource(idev, SYS_RES_IRQ, 0, NULL, NULL)) - outb(xiobase + com_scr, 0x80); /* no irq */ - else - outb(xiobase + com_scr, 0); + if (!COM_NOTAST4(flags)) { + if (bus_get_resource(idev, SYS_RES_IOPORT, 0, &io, + NULL) == 0) { + xiobase = io; + if (bus_get_resource(idev, SYS_RES_IRQ, 0, + NULL, NULL) == 0) + outb(xiobase + com_scr, 0x80); + else + outb(xiobase + com_scr, 0); + } + mcr_image = 0; } - mcr_image = 0; } #endif /* COM_MULTIPORT */ if (bus_get_resource(idev, SYS_RES_IRQ, 0, NULL, NULL) != 0) @@ -1011,7 +1015,7 @@ sioattach(dev) com->cfcr_image = CFCR_8BITS; com->dtr_wait = 3 * hz; com->loses_outints = COM_LOSESOUTINTS(flags) != 0; - com->no_irq = bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL); + com->no_irq = bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL) != 0; com->tx_fifo_size = 1; com->obufs[0].l_head = com->obuf1; com->obufs[1].l_head = com->obuf2; @@ -1170,8 +1174,8 @@ determined_type: ; printf(")"); masterdev = devclass_get_device(sio_devclass, COM_MPMASTER(flags)); - com->no_irq = bus_get_resource(masterdev, SYS_RES_IRQ, 0, NULL, - NULL); + com->no_irq = (masterdev == NULL || bus_get_resource(masterdev, + SYS_RES_IRQ, 0, NULL, NULL) != 0); } #endif /* COM_MULTIPORT */ if (unit == comconsole) diff --git a/sys/isa/sio.c b/sys/isa/sio.c index a409a55..0876620 100644 --- a/sys/isa/sio.c +++ b/sys/isa/sio.c @@ -692,7 +692,7 @@ sioprobe(dev) idev = dev; mcr_image = MCR_IENABLE; #ifdef COM_MULTIPORT - if (COM_ISMULTIPORT(flags) && !COM_NOTAST4(flags)) { + if (COM_ISMULTIPORT(flags)) { Port_t xiobase; u_long io; @@ -702,14 +702,18 @@ sioprobe(dev) device_get_unit(dev), COM_MPMASTER(flags)); idev = dev; } - if (bus_get_resource(idev, SYS_RES_IOPORT, 0, &io, NULL) == 0) { - xiobase = io; - if (bus_get_resource(idev, SYS_RES_IRQ, 0, NULL, NULL)) - outb(xiobase + com_scr, 0x80); /* no irq */ - else - outb(xiobase + com_scr, 0); + if (!COM_NOTAST4(flags)) { + if (bus_get_resource(idev, SYS_RES_IOPORT, 0, &io, + NULL) == 0) { + xiobase = io; + if (bus_get_resource(idev, SYS_RES_IRQ, 0, + NULL, NULL) == 0) + outb(xiobase + com_scr, 0x80); + else + outb(xiobase + com_scr, 0); + } + mcr_image = 0; } - mcr_image = 0; } #endif /* COM_MULTIPORT */ if (bus_get_resource(idev, SYS_RES_IRQ, 0, NULL, NULL) != 0) @@ -1011,7 +1015,7 @@ sioattach(dev) com->cfcr_image = CFCR_8BITS; com->dtr_wait = 3 * hz; com->loses_outints = COM_LOSESOUTINTS(flags) != 0; - com->no_irq = bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL); + com->no_irq = bus_get_resource(dev, SYS_RES_IRQ, 0, NULL, NULL) != 0; com->tx_fifo_size = 1; com->obufs[0].l_head = com->obuf1; com->obufs[1].l_head = com->obuf2; @@ -1170,8 +1174,8 @@ determined_type: ; printf(")"); masterdev = devclass_get_device(sio_devclass, COM_MPMASTER(flags)); - com->no_irq = bus_get_resource(masterdev, SYS_RES_IRQ, 0, NULL, - NULL); + com->no_irq = (masterdev == NULL || bus_get_resource(masterdev, + SYS_RES_IRQ, 0, NULL, NULL) != 0); } #endif /* COM_MULTIPORT */ if (unit == comconsole) -- cgit v1.1