Changeset 4fa05a32 in mainline for uspace/drv/uhci-hcd/transfer_list.c


Ignore:
Timestamp:
2011-03-17T22:29:16Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7b13d8e
Parents:
bf58895 (diff), 0fd82c9 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge development/ changes

File:
1 edited

Legend:

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

    rbf58895 r4fa05a32  
    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 */
     140void 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 */
     173void 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/*----------------------------------------------------------------------------*/
    131185/** Remove a transfer batch from the list and queue.
    132186 *
     
    163217            batch, pos, instance->name, batch->qh->next);
    164218}
    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  */
    175 void 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 }
    203219/**
    204220 * @}
Note: See TracChangeset for help on using the changeset viewer.