Ignore:
Timestamp:
2011-04-02T15:37:22Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0053fa38
Parents:
1273b86c
Message:

Use per endpoint control transfer mutex

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/host/device_keeper.c

    r1273b86c rd773285  
    5454        for (; i < USB_ADDRESS_COUNT; ++i) {
    5555                instance->devices[i].occupied = false;
    56                 instance->devices[i].control_used = false;
     56                instance->devices[i].control_used = 0;
    5757                instance->devices[i].handle = 0;
    5858                instance->devices[i].toggle_status[0] = 0;
     
    311311/*----------------------------------------------------------------------------*/
    312312void usb_device_keeper_use_control(usb_device_keeper_t *instance,
    313     usb_address_t address)
    314 {
    315         assert(instance);
    316         fibril_mutex_lock(&instance->guard);
    317         while (instance->devices[address].control_used) {
     313    usb_target_t target)
     314{
     315        assert(instance);
     316        const uint16_t ep = 1 << target.endpoint;
     317        fibril_mutex_lock(&instance->guard);
     318        while (instance->devices[target.address].control_used & ep) {
    318319                fibril_condvar_wait(&instance->change, &instance->guard);
    319320        }
    320         instance->devices[address].control_used = true;
     321        instance->devices[target.address].control_used |= ep;
    321322        fibril_mutex_unlock(&instance->guard);
    322323}
    323324/*----------------------------------------------------------------------------*/
    324325void usb_device_keeper_release_control(usb_device_keeper_t *instance,
    325     usb_address_t address)
    326 {
    327         assert(instance);
    328         fibril_mutex_lock(&instance->guard);
    329         instance->devices[address].control_used = false;
     326    usb_target_t target)
     327{
     328        assert(instance);
     329        const uint16_t ep = 1 << target.endpoint;
     330        fibril_mutex_lock(&instance->guard);
     331        assert((instance->devices[target.address].control_used & ep) != 0);
     332        instance->devices[target.address].control_used &= ~ep;
    330333        fibril_mutex_unlock(&instance->guard);
    331334        fibril_condvar_signal(&instance->change);
Note: See TracChangeset for help on using the changeset viewer.