Changeset d773285 in mainline


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

Location:
uspace
Files:
3 edited

Legend:

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

    r1273b86c rd773285  
    351351        if (batch->transfer_type == USB_TRANSFER_CONTROL) {
    352352                usb_device_keeper_use_control(
    353                     &instance->manager, batch->target.address);
     353                    &instance->manager, batch->target);
    354354        }
    355355        transfer_list_add_batch(list, batch);
     
    394394                        case USB_TRANSFER_CONTROL:
    395395                                usb_device_keeper_release_control(
    396                                     &instance->manager, batch->target.address);
     396                                    &instance->manager, batch->target);
    397397                                break;
    398398                        case USB_TRANSFER_INTERRUPT:
  • uspace/lib/usb/include/usb/host/device_keeper.h

    r1273b86c rd773285  
    5151        usb_speed_t speed;
    5252        bool occupied;
    53         bool control_used;
     53        uint16_t control_used;
    5454        uint16_t toggle_status[2];
    5555        devman_handle_t handle;
     
    9999
    100100void usb_device_keeper_use_control(usb_device_keeper_t *instance,
    101     usb_address_t address);
     101    usb_target_t target);
    102102
    103103void usb_device_keeper_release_control(usb_device_keeper_t *instance,
    104     usb_address_t address);
     104    usb_target_t target);
    105105
    106106#endif
  • 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.