Changeset ec6766a in mainline


Ignore:
Timestamp:
2013-07-27T08:30:53Z (11 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.

Location:
uspace/lib/usbhost
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/usb_endpoint_manager.h

    r8a23fef rec6766a  
    9292int usb_endpoint_manager_add_ep(usb_endpoint_manager_t *instance,
    9393    usb_address_t address, usb_endpoint_t endpoint, usb_direction_t direction,
    94     usb_transfer_type_t type, usb_speed_t speed, size_t max_packet_size,
    95     size_t data_size, ep_add_callback_t callback, void *arg);
     94    usb_transfer_type_t type, size_t max_packet_size, size_t data_size,
     95    ep_add_callback_t callback, void *arg);
    9696
    9797int usb_endpoint_manager_remove_ep(usb_endpoint_manager_t *instance,
  • uspace/lib/usbhost/src/ddf_helpers.c

    r8a23fef rec6766a  
    422422
    423423        /* Add default pipe on default address */
    424         ret = hcd_add_ep(hcd, 
     424        ret = hcd_add_ep(hcd,
    425425            default_target, USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL,
    426426            CTRL_PIPE_MIN_PACKET_SIZE, CTRL_PIPE_MIN_PACKET_SIZE);
  • uspace/lib/usbhost/src/hcd.c

    r8a23fef rec6766a  
    133133{
    134134        assert(hcd);
    135         usb_speed_t speed = USB_SPEED_MAX;
    136         const int ret = usb_endpoint_manager_get_info_by_address(
    137             &hcd->ep_manager, target.address, &speed);
    138         if (ret != EOK) {
    139                 return ret;
    140         }
    141135        return usb_endpoint_manager_add_ep(&hcd->ep_manager, target.address,
    142             target.endpoint, dir, type, speed, max_packet_size, size,
    143             register_helper, hcd);
     136            target.endpoint, dir, type, max_packet_size, size, register_helper,
     137            hcd);
    144138}
    145139
  • 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.