diff options
author | sos <sos@FreeBSD.org> | 2001-03-19 08:02:42 +0000 |
---|---|---|
committer | sos <sos@FreeBSD.org> | 2001-03-19 08:02:42 +0000 |
commit | 58cfc0f780e0a2393e0eb653aca52d3f52da0976 (patch) | |
tree | abefe1761fd85999371271df4ae67c2fda851ce6 | |
parent | e49d3850e3d55a9c19a537cf3a6da83747561c36 (diff) | |
download | FreeBSD-src-58cfc0f780e0a2393e0eb653aca52d3f52da0976.zip FreeBSD-src-58cfc0f780e0a2393e0eb653aca52d3f52da0976.tar.gz |
Cleanup the alloc/release code a bit.
Fix length error on the bmio resource.
Fix the irq release code, zero out free'd irq.
-rw-r--r-- | sys/dev/ata/ata-pci.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/sys/dev/ata/ata-pci.c b/sys/dev/ata/ata-pci.c index 30991f5..280c476 100644 --- a/sys/dev/ata/ata-pci.c +++ b/sys/dev/ata/ata-pci.c @@ -469,7 +469,7 @@ ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, start, end, count, flags); if (res) { start = rman_get_start(res) + 2; - end = start + ATA_ALTIOSIZE - 1; + end = rman_get_start(res) + ATA_ALTIOSIZE - 1; count = ATA_ALTIOSIZE; BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, SYS_RES_IOPORT, myrid, res); @@ -507,11 +507,11 @@ ata_pci_alloc_resource(device_t dev, device_t child, int type, int *rid, #endif } else { - /* primary and secondary channels share the same interrupt */ - sc->irqcnt++; + /* primary and secondary channels share interrupt, keep track */ if (!sc->irq) sc->irq = BUS_ALLOC_RESOURCE(device_get_parent(dev), dev, SYS_RES_IRQ, rid, 0, ~0, 1, flags); + sc->irqcnt++; return sc->irq; } } @@ -524,40 +524,33 @@ ata_pci_release_resource(device_t dev, device_t child, int type, int rid, { struct ata_pci_softc *sc = device_get_softc(dev); int channel = ((struct ata_softc *)device_get_softc(child))->channel; - int myrid = 0; if (type == SYS_RES_IOPORT) { switch (rid) { case ATA_IOADDR_RID: if (ATA_MASTERDEV(dev)) - myrid = 0; + return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, + SYS_RES_IOPORT, 0x0, r); else - myrid = 0x10 + 8 * channel; + return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, + SYS_RES_IOPORT, 0x10+8*channel, r); break; case ATA_ALTADDR_RID: if (ATA_MASTERDEV(dev)) - myrid = 0; + return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, + SYS_RES_IOPORT, 0x0, r); else - myrid = 0x14 + 8 * channel; + return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, + SYS_RES_IOPORT, 0x14+8*channel, r); break; case ATA_BMADDR_RID: - myrid = 0x20; - break; - + return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, + SYS_RES_IOPORT, 0x20, r); default: return ENOENT; } - - if (ATA_MASTERDEV(dev)) - /* make the parent just pass through the allocation. */ - return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, - SYS_RES_IOPORT, myrid, r); - else - /* we are using the parent resource directly. */ - return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, - SYS_RES_IOPORT, myrid, r); } if (type == SYS_RES_IRQ) { if (rid != ATA_IRQ_RID) @@ -567,16 +560,17 @@ ata_pci_release_resource(device_t dev, device_t child, int type, int rid, #ifdef __alpha__ return alpha_platform_release_ide_intr(channel, r); #else - return BUS_RELEASE_RESOURCE(device_get_parent(dev), - child, SYS_RES_IRQ, rid, r); + return BUS_RELEASE_RESOURCE(device_get_parent(dev), child, + SYS_RES_IRQ, rid, r); #endif } else { + /* primary and secondary channels share interrupt, keep track */ if (--sc->irqcnt) return 0; - - return BUS_RELEASE_RESOURCE(device_get_parent(dev), - dev, SYS_RES_IRQ, rid, r); + sc->irq = 0; + return BUS_RELEASE_RESOURCE(device_get_parent(dev), dev, + SYS_RES_IRQ, rid, r); } } return EINVAL; |