From 053a2b550fadfc3e31b3a4ff4992073808211e6f Mon Sep 17 00:00:00 2001 From: Warner Losh Date: Wed, 10 Nov 2004 00:33:05 +0000 Subject: [PATCH] Tweaks to the resource allocation to allow a few of my obscure cdrom/ata controller PC Card devices work better. --- sys/dev/ata/ata-card.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/sys/dev/ata/ata-card.c b/sys/dev/ata/ata-card.c index 4c63faeb85fa..490e06cebd81 100644 --- a/sys/dev/ata/ata-card.c +++ b/sys/dev/ata/ata-card.c @@ -105,11 +105,10 @@ ata_pccard_probe(device_t dev) { struct ata_channel *ch = device_get_softc(dev); struct resource *io, *altio; - int i, rid, len; + int i, rid; /* allocate the io range to get start and length */ rid = ATA_IOADDR_RID; - len = bus_get_resource_count(dev, SYS_RES_IOPORT, rid); io = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 0, ~0, ATA_IOSIZE, RF_ACTIVE); if (!io) @@ -125,7 +124,7 @@ ata_pccard_probe(device_t dev) * if we got more than the default ATA_IOSIZE ports, this is a device * where altio is located at offset 14 into "normal" io space. */ - if (len > ATA_IOSIZE) { + if (rman_get_size(io) > ATA_IOSIZE) { ch->r_io[ATA_ALTSTAT].res = io; ch->r_io[ATA_ALTSTAT].offset = 14; } @@ -161,10 +160,11 @@ ata_pccard_detach(device_t dev) free(ch->device[MASTER].param, M_ATA); ch->device[MASTER].param = NULL; ata_detach(dev); - bus_release_resource(dev, SYS_RES_IOPORT, - ATA_ALTADDR_RID, ch->r_io[ATA_ALTSTAT].res); - bus_release_resource(dev, SYS_RES_IOPORT, - ATA_IOADDR_RID, ch->r_io[ATA_DATA].res); + if (ch->r_io[ATA_ALTSTAT].res != ch->r_io[ATA_DATA].res) + bus_release_resource(dev, SYS_RES_IOPORT, ATA_ALTADDR_RID, + ch->r_io[ATA_ALTSTAT].res); + bus_release_resource(dev, SYS_RES_IOPORT, ATA_IOADDR_RID, + ch->r_io[ATA_DATA].res); for (i = ATA_DATA; i < ATA_MAX_RES; i++) ch->r_io[i].res = NULL; return 0;