diff options
Diffstat (limited to 'sys/dev/ata')
-rw-r--r-- | sys/dev/ata/ata-card.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/sys/dev/ata/ata-card.c b/sys/dev/ata/ata-card.c index 4c63fae..490e06c 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; |