Changeset 4deca9b in mainline for uspace/lib/usb/src


Ignore:
Timestamp:
2011-04-12T11:43:35Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
651b352
Parents:
1324ff3 (diff), 910ca3f (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:

Extensive cleanup, preparation for OHCI rework

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

Legend:

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

    r1324ff3 r4deca9b  
    4141void usb_transfer_batch_init(
    4242    usb_transfer_batch_t *instance,
    43     usb_target_t target,
    44     usb_transfer_type_t transfer_type,
    45     usb_speed_t speed,
    46     size_t max_packet_size,
     43                endpoint_t *ep,
    4744    char *buffer,
    48     char *transport_buffer,
     45    char *data_buffer,
    4946    size_t buffer_size,
    5047    char *setup_buffer,
     
    5451    void *arg,
    5552    ddf_fun_t *fun,
    56                 endpoint_t *ep,
    5753    void *private_data
    5854    )
     
    6056        assert(instance);
    6157        link_initialize(&instance->link);
    62         instance->target = target;
    63         instance->transfer_type = transfer_type;
    64         instance->speed = speed;
    65         instance->direction = ep->direction;
     58        instance->ep = ep;
    6659        instance->callback_in = func_in;
    6760        instance->callback_out = func_out;
    6861        instance->arg = arg;
    6962        instance->buffer = buffer;
    70         instance->transport_buffer = transport_buffer;
     63        instance->data_buffer = data_buffer;
    7164        instance->buffer_size = buffer_size;
    7265        instance->setup_buffer = setup_buffer;
    7366        instance->setup_size = setup_size;
    74         instance->max_packet_size = max_packet_size;
    7567        instance->fun = fun;
    7668        instance->private_data = private_data;
     
    7870        instance->next_step = NULL;
    7971        instance->error = EOK;
    80         instance->ep = ep;
    8172        endpoint_use(instance->ep);
    8273}
     
    10596        assert(instance);
    10697        assert(instance->callback_in);
     98        assert(instance->ep);
    10799
    108100        /* We are data in, we need data */
    109         memcpy(instance->buffer, instance->transport_buffer,
    110             instance->buffer_size);
     101        memcpy(instance->buffer, instance->data_buffer, instance->buffer_size);
    111102
    112103        usb_log_debug("Batch %p done (T%d.%d, %s %s in, %zuB): %s (%d).\n",
    113             instance,
    114             instance->target.address, instance->target.endpoint,
    115             usb_str_speed(instance->speed),
    116             usb_str_transfer_type_short(instance->transfer_type),
    117             instance->transfered_size,
    118             str_error(instance->error), instance->error);
     104            instance, instance->ep->address, instance->ep->endpoint,
     105            usb_str_speed(instance->ep->speed),
     106            usb_str_transfer_type_short(instance->ep->transfer_type),
     107            instance->transfered_size, str_error(instance->error), instance->error);
    119108
    120109        instance->callback_in(instance->fun, instance->error,
     
    132121
    133122        usb_log_debug("Batch %p done (T%d.%d, %s %s out): %s (%d).\n",
    134             instance,
    135             instance->target.address, instance->target.endpoint,
    136             usb_str_speed(instance->speed),
    137             usb_str_transfer_type_short(instance->transfer_type),
     123            instance, instance->ep->address, instance->ep->endpoint,
     124            usb_str_speed(instance->ep->speed),
     125            usb_str_transfer_type_short(instance->ep->transfer_type),
    138126            str_error(instance->error), instance->error);
    139127
  • uspace/lib/usb/src/host/device_keeper.c

    r1324ff3 r4deca9b  
    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.