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


Ignore:
Timestamp:
2011-03-21T23:42:08Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
11dd29b, 62f4212
Parents:
31b568e (diff), 87644b4 (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:

Fixes selecting a new USB address when max address has been reached.

Whitespace and code-style fixes, renames

File:
1 edited

Legend:

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

    r31b568e rb01995b  
    7979        if (!instance->queue_head)
    8080                return;
    81         /* Set both next and element to point to the same QH */
     81        /* Set both queue_head.next to point to the follower */
    8282        qh_set_next_qh(instance->queue_head, next->queue_head_pa);
    83         qh_set_element_qh(instance->queue_head, next->queue_head_pa);
    8483}
    8584/*----------------------------------------------------------------------------*/
     
    9897        usb_log_debug2("Queue %s: Adding batch(%p).\n", instance->name, batch);
    9998
    100         const uint32_t pa = addr_to_phys(batch_qh(batch));
    101         assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
    102 
    103         /* New batch will be added to the end of the current list
    104          * so set the link accordingly */
    105         qh_set_next_qh(batch_qh(batch), instance->queue_head->next);
    106 
    10799        fibril_mutex_lock(&instance->guard);
    108100
     101        qh_t *last_qh = NULL;
    109102        /* Add to the hardware queue. */
    110103        if (list_empty(&instance->batch_list)) {
    111104                /* There is nothing scheduled */
    112                 qh_t *qh = instance->queue_head;
    113                 assert(qh->element == qh->next);
    114                 qh_set_element_qh(qh, pa);
     105                last_qh = instance->queue_head;
    115106        } else {
    116107                /* There is something scheduled */
    117108                usb_transfer_batch_t *last = list_get_instance(
    118109                    instance->batch_list.prev, usb_transfer_batch_t, link);
    119                 qh_set_next_qh(batch_qh(last), pa);
    120         }
     110                last_qh = batch_qh(last);
     111        }
     112        const uint32_t pa = addr_to_phys(batch_qh(batch));
     113        assert((pa & LINK_POINTER_ADDRESS_MASK) == pa);
     114
     115        /* keep link */
     116        batch_qh(batch)->next = last_qh->next;
     117        qh_set_next_qh(last_qh, pa);
     118
    121119        /* Add to the driver list */
    122120        list_append(&batch->link, &instance->batch_list);
     
    174172{
    175173        fibril_mutex_lock(&instance->guard);
    176         while (list_empty(&instance->batch_list)) {
     174        while (!list_empty(&instance->batch_list)) {
    177175                link_t *current = instance->batch_list.next;
    178176                usb_transfer_batch_t *batch = list_get_instance(current, usb_transfer_batch_t, link);
     
    197195        assert(batch);
    198196        assert(batch_qh(batch));
     197        assert(fibril_mutex_is_locked(&instance->guard));
     198
    199199        usb_log_debug2(
    200200            "Queue %s: removing batch(%p).\n", instance->name, batch);
    201201
    202         const char * pos = NULL;
     202        const char *qpos = NULL;
    203203        /* Remove from the hardware queue */
    204         if (batch->link.prev == &instance->batch_list) {
     204        if (instance->batch_list.next == &batch->link) {
    205205                /* I'm the first one here */
    206                 qh_set_element_qh(instance->queue_head, batch_qh(batch)->next);
    207                 pos = "FIRST";
     206                assert((instance->queue_head->next & LINK_POINTER_ADDRESS_MASK)
     207                    == addr_to_phys(batch_qh(batch)));
     208                instance->queue_head->next = batch_qh(batch)->next;
     209                qpos = "FIRST";
    208210        } else {
    209211                usb_transfer_batch_t *prev =
    210212                    list_get_instance(batch->link.prev, usb_transfer_batch_t, link);
    211                 qh_set_next_qh(batch_qh(prev), batch_qh(batch)->next);
    212                 pos = "NOT FIRST";
    213         }
    214         /* Remove from the driver list */
     213                assert((batch_qh(prev)->next & LINK_POINTER_ADDRESS_MASK)
     214                    == addr_to_phys(batch_qh(batch)));
     215                batch_qh(prev)->next = batch_qh(batch)->next;
     216                qpos = "NOT FIRST";
     217        }
     218        /* Remove from the batch list */
    215219        list_remove(&batch->link);
    216         usb_log_debug("Batch(%p) removed (%s) from %s, next element %x.\n",
    217             batch, pos, instance->name, batch_qh(batch)->next);
     220        usb_log_debug("Batch(%p) removed (%s) from %s, next %x.\n",
     221            batch, qpos, instance->name, batch_qh(batch)->next);
    218222}
    219223/**
Note: See TracChangeset for help on using the changeset viewer.