Changeset 85c47729 in mainline for uspace/lib/usb/src


Ignore:
Timestamp:
2011-04-08T13:25:58Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
61727bf
Parents:
8b74997f (diff), 4b39af4 (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:

Per endpoint communication mutex

Location:
uspace/lib/usb/src/host
Files:
3 edited

Legend:

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

    r8b74997f r85c47729  
    7979        instance->error = EOK;
    8080        instance->ep = ep;
     81        endpoint_use(instance->ep);
    8182}
    8283/*----------------------------------------------------------------------------*/
     
    8687 *
    8788 */
    88 void usb_transfer_batch_finish(usb_transfer_batch_t *instance, int error)
     89void usb_transfer_batch_finish(usb_transfer_batch_t *instance)
    8990{
    9091        assert(instance);
    91         instance->error = error;
     92        assert(instance->ep);
     93        endpoint_release(instance->ep);
    9294        instance->next_step(instance);
    9395}
  • uspace/lib/usb/src/host/device_keeper.c

    r8b74997f r85c47729  
    264264        return instance->devices[address].speed;
    265265}
    266 /*----------------------------------------------------------------------------*/
    267 void usb_device_keeper_use_control(
    268     usb_device_keeper_t *instance, usb_target_t target)
    269 {
    270         assert(instance);
    271         const uint16_t ep = 1 << target.endpoint;
    272         fibril_mutex_lock(&instance->guard);
    273         while (instance->devices[target.address].control_used & ep) {
    274                 fibril_condvar_wait(&instance->change, &instance->guard);
    275         }
    276         instance->devices[target.address].control_used |= ep;
    277         fibril_mutex_unlock(&instance->guard);
    278 }
    279 /*----------------------------------------------------------------------------*/
    280 void usb_device_keeper_release_control(
    281     usb_device_keeper_t *instance, usb_target_t target)
    282 {
    283         assert(instance);
    284         const uint16_t ep = 1 << target.endpoint;
    285         fibril_mutex_lock(&instance->guard);
    286         assert((instance->devices[target.address].control_used & ep) != 0);
    287         instance->devices[target.address].control_used &= ~ep;
    288         fibril_mutex_unlock(&instance->guard);
    289         fibril_condvar_signal(&instance->change);
    290 }
    291266/**
    292267 * @}
  • uspace/lib/usb/src/host/endpoint.c

    r8b74997f r85c47729  
    3434 */
    3535
     36#include <assert.h>
    3637#include <errno.h>
    3738#include <usb/host/endpoint.h>
     
    4950        instance->max_packet_size = max_packet_size;
    5051        instance->toggle = 0;
     52        instance->active = false;
     53        fibril_mutex_initialize(&instance->guard);
     54        fibril_condvar_initialize(&instance->avail);
    5155        link_initialize(&instance->same_device_eps);
    5256        return EOK;
     
    5660{
    5761        assert(instance);
     62        assert(!instance->active);
    5863        list_remove(&instance->same_device_eps);
    5964        free(instance);
     65}
     66/*----------------------------------------------------------------------------*/
     67void endpoint_use(endpoint_t *instance)
     68{
     69        assert(instance);
     70        fibril_mutex_lock(&instance->guard);
     71        while (instance->active)
     72                fibril_condvar_wait(&instance->avail, &instance->guard);
     73        instance->active = true;
     74        fibril_mutex_unlock(&instance->guard);
     75}
     76/*----------------------------------------------------------------------------*/
     77void endpoint_release(endpoint_t *instance)
     78{
     79        assert(instance);
     80        fibril_mutex_lock(&instance->guard);
     81        instance->active = false;
     82        fibril_mutex_unlock(&instance->guard);
     83        fibril_condvar_signal(&instance->avail);
    6084}
    6185/*----------------------------------------------------------------------------*/
Note: See TracChangeset for help on using the changeset viewer.