Properly react to allocation failures.
        Correct the former patch to the way it would have looked after review.

Approved by: re@ (scottl)
This commit is contained in:
sos 2005-10-12 20:17:34 +00:00
parent cd55799acc
commit 4ecb87dfee
2 changed files with 24 additions and 19 deletions

View File

@ -915,8 +915,10 @@ ata_ali_allocate(device_t dev)
struct ata_channel *ch = device_get_softc(dev);
/* setup the usual register normal pci style */
ata_pci_allocate(dev);
if (ata_pci_allocate(dev))
return ENXIO;
/* older chips can't do 48bit DMA transfers */
if (ctlr->chip->chiprev <= 0xc4)
ch->flags |= ATA_NO_48BIT_DMA;
@ -2137,7 +2139,8 @@ ata_nvidia_allocate(device_t dev)
struct ata_channel *ch = device_get_softc(dev);
/* setup the usual register normal pci style */
ata_pci_allocate(dev);
if (ata_pci_allocate(dev))
return ENXIO;
ch->r_io[ATA_SSTATUS].res = ctlr->r_res2;
ch->r_io[ATA_SSTATUS].offset = (ch->unit << 6);
@ -3819,7 +3822,8 @@ ata_sis_allocate(device_t dev)
struct ata_channel *ch = device_get_softc(dev);
/* setup the usual register normal pci style */
ata_pci_allocate(dev);
if (ata_pci_allocate(dev))
return ENXIO;
ch->r_io[ATA_SSTATUS].res = ctlr->r_res2;
ch->r_io[ATA_SSTATUS].offset = (ch->unit << 4);
@ -4024,7 +4028,6 @@ ata_via_allocate(device_t dev)
struct ata_pci_controller *ctlr = device_get_softc(device_get_parent(dev));
struct ata_channel *ch = device_get_softc(dev);
/* newer SATA chips has resources in one BAR for each channel */
if (ctlr->chip->cfg2 & VIABAR) {
struct resource *r_io;
@ -4050,8 +4053,10 @@ ata_via_allocate(device_t dev)
}
ata_generic_hw(dev);
}
else
ata_pci_allocate(dev);
else {
if (ata_pci_allocate(dev))
return ENXIO;
}
ch->r_io[ATA_SSTATUS].res = ctlr->r_res2;
ch->r_io[ATA_SSTATUS].offset = (ch->unit << ctlr->chip->cfg1);

View File

@ -760,26 +760,26 @@ acd_geom_start(struct bio *bp)
}
else {
u_int pos, size = cdp->iomax - cdp->iomax % bp->bio_to->sectorsize;
struct bio *bp2, *first, **next = &first;
struct bio *bp2, *bp3;
for (pos = 0; pos < bp->bio_length; pos += size) {
if (!(bp2 = g_clone_bio(bp))) {
bp->bio_error = ENOMEM;
break;
}
if (!(bp2 = g_clone_bio(bp)))
g_io_deliver(bp, EIO);
for (pos = 0; bp2; pos += size) {
bp3 = NULL;
bp2->bio_done = g_std_done;
bp2->bio_to = bp->bio_to;
bp2->bio_offset += pos;
bp2->bio_data += pos;
bp2->bio_length = MIN(size, bp->bio_length - pos);
bp2->bio_length = bp->bio_length - pos;
if (bp2->bio_length > size) {
bp2->bio_length = size;
if (!(bp3 = g_clone_bio(bp)))
bp->bio_error = ENOMEM;
}
bp2->bio_pblkno = bp2->bio_offset / bp2->bio_to->sectorsize;
*next = bp2;
next = (struct bio **)&bp2->bio_driver1;
}
*next = NULL;
while ((bp2 = first) != NULL) {
first = (struct bio *)bp2->bio_driver1;
acd_strategy(bp2);
bp2 = bp3;
}
}
}