Changeset 84de606d in mainline


Ignore:
Timestamp:
2011-05-08T13:37:16Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
eb2f7dd
Parents:
79784ef8
Message:

Device keeper can tell handle by USB address

Location:
uspace/lib/usb
Files:
2 edited

Legend:

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

    r79784ef8 r84de606d  
    8080    devman_handle_t handle);
    8181
     82bool usb_device_keeper_find_by_address(usb_device_keeper_t *instance,
     83    usb_address_t address, devman_handle_t *handle);
     84
    8285usb_speed_t usb_device_keeper_get_speed(usb_device_keeper_t *instance,
    8386    usb_address_t address);
  • uspace/lib/usb/src/host/device_keeper.c

    r79784ef8 r84de606d  
    157157        return ENOENT;
    158158}
     159
     160/** Find devman handled assigned to USB address.
     161 *
     162 * @param[in] instance Device keeper structure to use.
     163 * @param[in] address Address the caller wants to find.
     164 * @param[out] handle Where to store found handle.
     165 * @return Whether such address is currently occupied.
     166 */
     167bool usb_device_keeper_find_by_address(usb_device_keeper_t *instance,
     168    usb_address_t address, devman_handle_t *handle)
     169{
     170        assert(instance);
     171        fibril_mutex_lock(&instance->guard);
     172        if ((address < 0) || (address >= USB_ADDRESS_COUNT)) {
     173                fibril_mutex_unlock(&instance->guard);
     174                return false;
     175        }
     176        if (!instance->devices[address].occupied) {
     177                fibril_mutex_unlock(&instance->guard);
     178                return false;
     179        }
     180
     181        if (handle != NULL) {
     182                *handle = instance->devices[address].handle;
     183        }
     184
     185        fibril_mutex_unlock(&instance->guard);
     186        return true;
     187}
     188
    159189/*----------------------------------------------------------------------------*/
    160190/** Get speed associated with the address
Note: See TracChangeset for help on using the changeset viewer.