Ignore:
Timestamp:
2011-09-13T12:46:03Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3a8370c
Parents:
a837544
Message:

libusbhost: Don't include direction in endpoint hash, make BIDIRECTIONAL match both directions.

This servers dual purpose:
1) Prevents registering IN and OUT endpoints if there already is a BIDIRECTIONAL endpoint with the same address and number
2) BIDIRECTIONAL endpoints are found when searching for any direction, thus control transfers don't need special handling in batch preparation.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/usb_endpoint_manager.c

    ra837544 r4cbb6e4  
    4545static hash_index_t node_hash(unsigned long key[])
    4646{
    47         hash_index_t hash = 0;
    48         unsigned i = 0;
    49         for (;i < MAX_KEYS; ++i) {
    50                 hash ^= key[i];
    51         }
    52         hash %= BUCKET_COUNT;
    53         return hash;
     47        /* USB endpoints use 4 bits, thus ((key[0] << 4) | key[1])
     48         * produces unique value for every address.endpoint pair */
     49        return ((key[0] << 4) | key[1]) % BUCKET_COUNT;
    5450}
    5551/*----------------------------------------------------------------------------*/
     
    6359        switch (keys) {
    6460        case 3:
    65                 match = match && (key[2] == node->ep->direction);
     61                match = match &&
     62                    ((key[2] == node->ep->direction)
     63                    || (node->ep->direction == USB_DIRECTION_BOTH));
    6664        case 2:
    6765                match = match && (key[1] == (unsigned long)node->ep->endpoint);
Note: See TracChangeset for help on using the changeset viewer.