Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ata/src/ata.c

    r743f2cdd r0dab4850  
    11/*
    2  * Copyright (c) 2024 Jiri Svoboda
     2 * Copyright (c) 2025 Jiri Svoboda
    33 * All rights reserved.
    44 *
     
    151151{
    152152        ata_channel_t *chan;
     153        int i;
    153154
    154155        chan = calloc(1, sizeof(ata_channel_t));
     
    162163        fibril_mutex_initialize(&chan->irq_lock);
    163164        fibril_condvar_initialize(&chan->irq_cv);
     165
     166        for (i = 0; i < MAX_DEVICES; i++)
     167                chan->device[i].chan = chan;
    164168
    165169        *rchan = chan;
     
    253257
    254258        for (i = 0; i < MAX_DEVICES; i++) {
     259                if (chan->device[i].present == false)
     260                        continue;
     261
    255262                rc = ata_device_remove(&chan->device[i]);
    256263                if (rc != EOK) {
    257264                        ata_msg_error(chan, "Unable to remove device %d.", i);
     265                        fibril_mutex_unlock(&chan->lock);
    258266                        return rc;
    259267                }
     
    262270        ata_bd_fini_irq(chan);
    263271        fibril_mutex_unlock(&chan->lock);
    264 
    265         return EOK;
     272        free(chan);
     273
     274        return rc;
    266275}
    267276
     
    493502        unsigned i;
    494503
    495         d->chan = chan;
    496504        d->device_id = device_id;
    497505        d->present = false;
     
    15291537         * exceed DMA buffer size.
    15301538         */
    1531         dma_maxnb = d->chan->params.max_dma_xfer / d->block_size;
    1532         if (dma_maxnb < maxnb)
    1533                 maxnb = dma_maxnb;
     1539        if (d->chan->params.use_dma) {
     1540                dma_maxnb = d->chan->params.max_dma_xfer / d->block_size;
     1541                if (dma_maxnb < maxnb)
     1542                        maxnb = dma_maxnb;
     1543        }
    15341544
    15351545        return maxnb;
Note: See TracChangeset for help on using the changeset viewer.