Changeset e50cd7f in mainline for uspace/lib/usb/src/host/endpoint.c


Ignore:
Timestamp:
2011-04-17T19:17:55Z (14 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
63517c2, cfbbe1d3
Parents:
ef354b6 (diff), 8595577b (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:

new report structure fixes

File:
1 edited

Legend:

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

    ref354b6 re50cd7f  
    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;
    51         link_initialize(&instance->same_device_eps);
     52        instance->active = false;
     53        fibril_mutex_initialize(&instance->guard);
     54        fibril_condvar_initialize(&instance->avail);
     55        endpoint_clear_hc_data(instance);
    5256        return EOK;
    5357}
     
    5660{
    5761        assert(instance);
    58         list_remove(&instance->same_device_eps);
     62        assert(!instance->active);
    5963        free(instance);
     64}
     65/*----------------------------------------------------------------------------*/
     66void endpoint_set_hc_data(endpoint_t *instance,
     67    void *data, int (*toggle_get)(void *), void (*toggle_set)(void *, int))
     68{
     69        assert(instance);
     70        instance->hc_data.data = data;
     71        instance->hc_data.toggle_get = toggle_get;
     72        instance->hc_data.toggle_set = toggle_set;
     73}
     74/*----------------------------------------------------------------------------*/
     75void endpoint_clear_hc_data(endpoint_t *instance)
     76{
     77        assert(instance);
     78        instance->hc_data.data = NULL;
     79        instance->hc_data.toggle_get = NULL;
     80        instance->hc_data.toggle_set = NULL;
     81}
     82/*----------------------------------------------------------------------------*/
     83void endpoint_use(endpoint_t *instance)
     84{
     85        assert(instance);
     86        fibril_mutex_lock(&instance->guard);
     87        while (instance->active)
     88                fibril_condvar_wait(&instance->avail, &instance->guard);
     89        instance->active = true;
     90        fibril_mutex_unlock(&instance->guard);
     91}
     92/*----------------------------------------------------------------------------*/
     93void endpoint_release(endpoint_t *instance)
     94{
     95        assert(instance);
     96        fibril_mutex_lock(&instance->guard);
     97        instance->active = false;
     98        fibril_mutex_unlock(&instance->guard);
     99        fibril_condvar_signal(&instance->avail);
    60100}
    61101/*----------------------------------------------------------------------------*/
     
    63103{
    64104        assert(instance);
     105        if (instance->hc_data.toggle_get)
     106                instance->toggle =
     107                    instance->hc_data.toggle_get(instance->hc_data.data);
    65108        return (int)instance->toggle;
    66109}
     
    70113        assert(instance);
    71114        assert(toggle == 0 || toggle == 1);
     115        if (instance->hc_data.toggle_set)
     116                instance->hc_data.toggle_set(instance->hc_data.data, toggle);
    72117        instance->toggle = toggle;
    73118}
    74119/*----------------------------------------------------------------------------*/
    75 void endpoint_toggle_reset(link_t *ep)
     120void endpoint_toggle_reset_filtered(endpoint_t *instance, usb_target_t target)
    76121{
    77         endpoint_t *instance =
    78             list_get_instance(ep, endpoint_t, same_device_eps);
    79122        assert(instance);
    80         instance->toggle = 0;
    81 }
    82 /*----------------------------------------------------------------------------*/
    83 void endpoint_toggle_reset_filtered(link_t *ep, usb_endpoint_t epn)
    84 {
    85         endpoint_t *instance =
    86             list_get_instance(ep, endpoint_t, same_device_eps);
    87         assert(instance);
    88         if (instance->endpoint == epn)
    89                 instance->toggle = 0;
     123        if (instance->address == target.address &&
     124            (instance->endpoint == target.endpoint || target.endpoint == 0))
     125                endpoint_toggle_set(instance, 0);
    90126}
    91127/**
Note: See TracChangeset for help on using the changeset viewer.