Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci-hcd/transfer_list.c

    ra963a68 r17ceb72  
    129129}
    130130/*----------------------------------------------------------------------------*/
    131 /** Check list for finished batches.
    132  *
    133  * @param[in] instance List to use.
    134  * @return Error code
    135  *
    136  * Creates a local list of finished batches and calls next_step on each and
    137  * every one. This is safer because next_step may theoretically access
    138  * this transfer list leading to the deadlock if its done inline.
    139  */
    140 void transfer_list_remove_finished(transfer_list_t *instance)
    141 {
    142         assert(instance);
    143 
    144         LIST_INITIALIZE(done);
    145 
    146         fibril_mutex_lock(&instance->guard);
    147         link_t *current = instance->batch_list.next;
    148         while (current != &instance->batch_list) {
    149                 link_t *next = current->next;
    150                 batch_t *batch = list_get_instance(current, batch_t, link);
    151 
    152                 if (batch_is_complete(batch)) {
    153                         /* Save for post-processing */
    154                         transfer_list_remove_batch(instance, batch);
    155                         list_append(current, &done);
    156                 }
    157                 current = next;
    158         }
    159         fibril_mutex_unlock(&instance->guard);
    160 
    161         while (!list_empty(&done)) {
    162                 link_t *item = done.next;
    163                 list_remove(item);
    164                 batch_t *batch = list_get_instance(item, batch_t, link);
    165                 batch->next_step(batch);
    166         }
    167 }
    168 /*----------------------------------------------------------------------------*/
    169 /** Walk the list and abort all batches.
    170  *
    171  * @param[in] instance List to use.
    172  */
    173 void transfer_list_abort_all(transfer_list_t *instance)
    174 {
    175         fibril_mutex_lock(&instance->guard);
    176         while (list_empty(&instance->batch_list)) {
    177                 link_t *current = instance->batch_list.next;
    178                 batch_t *batch = list_get_instance(current, batch_t, link);
    179                 transfer_list_remove_batch(instance, batch);
    180                 batch_abort(batch);
    181         }
    182         fibril_mutex_unlock(&instance->guard);
    183 }
    184 /*----------------------------------------------------------------------------*/
    185131/** Remove a transfer batch from the list and queue.
    186132 *
     
    217163            batch, pos, instance->name, batch->qh->next);
    218164}
     165/*----------------------------------------------------------------------------*/
     166/** Check list for finished batches.
     167 *
     168 * @param[in] instance List to use.
     169 * @return Error code
     170 *
     171 * Creates a local list of finished batches and calls next_step on each and
     172 * every one. This is safer because next_step may theoretically access
     173 * this transfer list leading to the deadlock if its done inline.
     174 */
     175void transfer_list_remove_finished(transfer_list_t *instance)
     176{
     177        assert(instance);
     178
     179        LIST_INITIALIZE(done);
     180
     181        fibril_mutex_lock(&instance->guard);
     182        link_t *current = instance->batch_list.next;
     183        while (current != &instance->batch_list) {
     184                link_t *next = current->next;
     185                batch_t *batch = list_get_instance(current, batch_t, link);
     186
     187                if (batch_is_complete(batch)) {
     188                        /* Save for post-processing */
     189                        transfer_list_remove_batch(instance, batch);
     190                        list_append(current, &done);
     191                }
     192                current = next;
     193        }
     194        fibril_mutex_unlock(&instance->guard);
     195
     196        while (!list_empty(&done)) {
     197                link_t *item = done.next;
     198                list_remove(item);
     199                batch_t *batch = list_get_instance(item, batch_t, link);
     200                batch->next_step(batch);
     201        }
     202}
    219203/**
    220204 * @}
Note: See TracChangeset for help on using the changeset viewer.