Tweaks to the resource allocation to allow a few of my obscure

cdrom/ata controller PC Card devices work better.
This commit is contained in:
Warner Losh 2004-11-10 00:33:05 +00:00
parent 889e265c72
commit 053a2b550f

View File

@ -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;