Ignore:
Timestamp:
2013-07-27T08:30:53Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3cc55b47
Parents:
8a23fef
Message:

libusbhost: Remove speed argument from add_ep.

It can be queried internally.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/usb_endpoint_manager.c

    r8a23fef rec6766a  
    286286int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance,
    287287    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
    288     usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size,
    289     size_t data_size, ep_add_callback_t callback, void *arg)
     288    usb_transfer_type_t type, size_t max_packet_size, size_t data_size,
     289    ep_add_callback_t callback, void *arg)
    290290{
    291291        assert(instance);
    292292        if (instance->bw_count == NULL)
    293293                return ENOTSUP;
    294         if (address < 0)
    295                 return EINVAL;
    296 
    297         const size_t bw =
    298             instance->bw_count(speed, type, data_size, max_packet_size);
    299 
    300         fibril_mutex_lock(&instance->guard);
    301         /* Check for available bandwidth */
    302         if (bw > instance->free_bw) {
    303                 fibril_mutex_unlock(&instance->guard);
    304                 return ENOSPC;
     294        if (!usb_address_is_valid(address))
     295                return EINVAL;
     296
     297
     298        fibril_mutex_lock(&instance->guard);
     299        /* Check for speed and address */
     300        if (!instance->devices[address].occupied) {
     301                fibril_mutex_unlock(&instance->guard);
     302                return ENOENT;
    305303        }
    306304
     
    310308                fibril_mutex_unlock(&instance->guard);
    311309                return EEXISTS;
     310        }
     311
     312        const usb_speed_t speed = instance->devices[address].speed;
     313        const size_t bw =
     314            instance->bw_count(speed, type, data_size, max_packet_size);
     315
     316        /* Check for available bandwidth */
     317        if (bw > instance->free_bw) {
     318                fibril_mutex_unlock(&instance->guard);
     319                return ENOSPC;
    312320        }
    313321
Note: See TracChangeset for help on using the changeset viewer.