Changeset 8a23fef in mainline


Ignore:
Timestamp:
2013-07-27T08:17:36Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ec6766a
Parents:
3aac088
Message:

libusbhost: Merge _remove_address and _release_address.

Location:
uspace/lib/usbhost
Files:
3 edited

Legend:

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

    r3aac088 r8a23fef  
    8686int usb_endpoint_manager_unregister_ep(
    8787    usb_endpoint_manager_t *instance, endpoint_t *ep);
     88
    8889endpoint_t * usb_endpoint_manager_find_ep(usb_endpoint_manager_t *instance,
    8990    usb_address_t address, usb_endpoint_t ep, usb_direction_t direction);
     
    101102    usb_target_t target, bool all);
    102103
    103 void usb_endpoint_manager_remove_address(usb_endpoint_manager_t *instance,
     104int usb_endpoint_manager_remove_address(usb_endpoint_manager_t *instance,
    104105    usb_address_t address, ep_remove_callback_t callback, void *arg);
    105106
    106107int usb_endpoint_manager_request_address(usb_endpoint_manager_t *instance,
    107108    usb_address_t *address, bool strict, usb_speed_t speed);
    108 
    109 int usb_endpoint_manager_release_address(usb_endpoint_manager_t *instance,
    110     usb_address_t address);
    111109
    112110int usb_endpoint_manager_get_info_by_address(usb_endpoint_manager_t *instance,
  • uspace/lib/usbhost/src/hcd.c

    r3aac088 r8a23fef  
    117117{
    118118        assert(hcd);
    119         usb_endpoint_manager_remove_address(&hcd->ep_manager, address,
     119        return usb_endpoint_manager_remove_address(&hcd->ep_manager, address,
    120120            unregister_helper_warn, hcd);
    121         usb_endpoint_manager_release_address(&hcd->ep_manager, address);
    122         return EOK;
    123121}
    124122
  • uspace/lib/usbhost/src/usb_endpoint_manager.c

    r3aac088 r8a23fef  
    369369{
    370370        assert(instance);
    371         if (!usb_target_is_valid(target)) {
    372                 return EINVAL;
    373         }
    374 
    375         int rc = ENOENT;
     371        if (!usb_target_is_valid(target))
     372                return EINVAL;
     373
     374        int ret = ENOENT;
    376375
    377376        fibril_mutex_lock(&instance->guard);
     
    381380                    && (all || ep->endpoint == target.endpoint)) {
    382381                        endpoint_toggle_set(ep, 0);
    383                         rc = EOK;
     382                        ret = EOK;
    384383                }
    385384        }
    386385        fibril_mutex_unlock(&instance->guard);
    387         return rc;
     386        return ret;
    388387}
    389388
     
    397396 * @return Error code.
    398397 */
    399 void usb_endpoint_manager_remove_address(usb_endpoint_manager_t *instance,
     398int usb_endpoint_manager_remove_address(usb_endpoint_manager_t *instance,
    400399    usb_address_t address, ep_remove_callback_t callback, void *arg)
    401400{
    402         assert(address >= 0);
    403         assert(instance);
    404         fibril_mutex_lock(&instance->guard);
     401        assert(instance);
     402        if (!usb_address_is_valid(address))
     403                return EINVAL;
     404
     405        fibril_mutex_lock(&instance->guard);
     406
     407        const int ret = instance->devices[address].occupied ? EOK : ENOENT;
     408        instance->devices[address].occupied = false;
     409
    405410        list_foreach(*get_list(instance, address), iterator) {
    406411                endpoint_t *ep = endpoint_get_instance(iterator);
     
    414419        }
    415420        fibril_mutex_unlock(&instance->guard);
     421        return ret;
    416422}
    417423
     
    463469}
    464470
    465 /** Release used USB address.
    466  *
    467  * @param[in] instance Device manager structure to use.
    468  * @param[in] address Device address
    469  * @return Error code.
    470  */
    471 int usb_endpoint_manager_release_address(
    472     usb_endpoint_manager_t *instance, usb_address_t address)
    473 {
    474         assert(instance);
    475         if (!usb_address_is_valid(address))
    476                 return EINVAL;
    477 
    478         fibril_mutex_lock(&instance->guard);
    479 
    480         const int rc = instance->devices[address].occupied ? EOK : ENOENT;
    481         instance->devices[address].occupied = false;
    482 
    483         fibril_mutex_unlock(&instance->guard);
    484         return rc;
    485 }
    486 
    487471/** Get speed assigned to USB address.
    488472 *
     
    502486        fibril_mutex_lock(&instance->guard);
    503487
    504         const int rc = instance->devices[address].occupied ? EOK : ENOENT;
     488        const int ret = instance->devices[address].occupied ? EOK : ENOENT;
    505489        if (speed && instance->devices[address].occupied) {
    506490                *speed = instance->devices[address].speed;
     
    508492
    509493        fibril_mutex_unlock(&instance->guard);
    510         return rc;
     494        return ret;
    511495}
    512496/**
Note: See TracChangeset for help on using the changeset viewer.