Ignore:
Timestamp:
2011-04-29T13:43:01Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a81a1d09
Parents:
380e0364 (diff), f19f1b7 (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/lib/usb/src/host/device_keeper.c

    r380e0364 re1dbcbc  
    4848{
    4949        assert(instance);
    50         fibril_mutex_initialize(&instance->guard);
    51         fibril_condvar_initialize(&instance->change);
    52         instance->last_address = 0;
    5350        unsigned i = 0;
    5451        for (; i < USB_ADDRESS_COUNT; ++i) {
     
    6057        // (it is needed to allow smooth registration at default address)
    6158        instance->devices[0].occupied = true;
     59        instance->last_address = 0;
     60        fibril_mutex_initialize(&instance->guard);
    6261}
    63 /*----------------------------------------------------------------------------*/
    64 /** Attempt to obtain address 0, blocks.
    65  *
    66  * @param[in] instance Device keeper structure to use.
    67  * @param[in] speed Speed of the device requesting default address.
    68  */
    69 void usb_device_keeper_reserve_default_address(
    70     usb_device_keeper_t *instance, usb_speed_t speed)
    71 {
    72         assert(instance);
    73         fibril_mutex_lock(&instance->guard);
    74         while (instance->devices[USB_ADDRESS_DEFAULT].occupied) {
    75                 fibril_condvar_wait(&instance->change, &instance->guard);
    76         }
    77         instance->devices[USB_ADDRESS_DEFAULT].occupied = true;
    78         instance->devices[USB_ADDRESS_DEFAULT].speed = speed;
    79         fibril_mutex_unlock(&instance->guard);
    80 }
    81 /*----------------------------------------------------------------------------*/
    82 /** Attempt to obtain address 0, blocks.
    83  *
    84  * @param[in] instance Device keeper structure to use.
    85  * @param[in] speed Speed of the device requesting default address.
    86  */
    87 void usb_device_keeper_release_default_address(usb_device_keeper_t *instance)
    88 {
    89         assert(instance);
    90         fibril_mutex_lock(&instance->guard);
    91         instance->devices[USB_ADDRESS_DEFAULT].occupied = false;
    92         fibril_mutex_unlock(&instance->guard);
    93         fibril_condvar_signal(&instance->change);
    94 }
    95 /*----------------------------------------------------------------------------*/
    9662/*----------------------------------------------------------------------------*/
    9763/** Get a free USB address
     
    12086        assert(new_address != USB_ADDRESS_DEFAULT);
    12187        assert(instance->devices[new_address].occupied == false);
     88
    12289        instance->devices[new_address].occupied = true;
    12390        instance->devices[new_address].speed = speed;
    12491        instance->last_address = new_address;
     92
    12593        fibril_mutex_unlock(&instance->guard);
    12694        return new_address;
     
    138106        assert(instance);
    139107        fibril_mutex_lock(&instance->guard);
     108
    140109        assert(address > 0);
    141110        assert(address <= USB11_ADDRESS_MAX);
    142111        assert(instance->devices[address].occupied);
     112
    143113        instance->devices[address].handle = handle;
    144114        fibril_mutex_unlock(&instance->guard);
     
    159129        fibril_mutex_lock(&instance->guard);
    160130        assert(instance->devices[address].occupied);
     131
    161132        instance->devices[address].occupied = false;
    162133        fibril_mutex_unlock(&instance->guard);
     
    177148        while (address <= USB11_ADDRESS_MAX) {
    178149                if (instance->devices[address].handle == handle) {
     150                        assert(instance->devices[address].occupied);
    179151                        fibril_mutex_unlock(&instance->guard);
    180152                        return address;
     
    198170        assert(address >= 0);
    199171        assert(address <= USB11_ADDRESS_MAX);
     172
    200173        return instance->devices[address].speed;
    201174}
Note: See TracChangeset for help on using the changeset viewer.