Ignore:
Timestamp:
2013-07-26T13:40:58Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2838486
Parents:
b0fc92c
Message:

libusbhost: Remove devman handle information from usb_device_manager.

File:
1 edited

Legend:

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

    rb0fc92c r059d507  
    7575        for (unsigned i = 0; i < USB_ADDRESS_COUNT; ++i) {
    7676                instance->devices[i].occupied = false;
    77                 instance->devices[i].handle = 0;
    7877                instance->devices[i].speed = USB_SPEED_MAX;
    7978        }
     
    115114        }
    116115        assert(instance->devices[*address].occupied == false);
    117         assert(instance->devices[*address].handle == 0);
    118116        assert(*address != USB_ADDRESS_DEFAULT || strict);
    119117
     
    121119        instance->devices[*address].speed = speed;
    122120
    123         fibril_mutex_unlock(&instance->guard);
    124         return EOK;
    125 }
    126 
    127 /** Bind USB address to devman handle.
    128  *
    129  * @param[in] instance Device manager structure to use.
    130  * @param[in] address Device address
    131  * @param[in] handle Devman handle of the device.
    132  * @return Error code.
    133  * @note Won't accept binding for default address.
    134  */
    135 int usb_device_manager_bind_address(usb_device_manager_t *instance,
    136     usb_address_t address, devman_handle_t handle)
    137 {
    138         if ((address <= 0) || (address >= USB_ADDRESS_COUNT)) {
    139                 return EINVAL;
    140         }
    141         assert(instance);
    142 
    143         fibril_mutex_lock(&instance->guard);
    144         /* Not reserved */
    145         if (!instance->devices[address].occupied) {
    146                 fibril_mutex_unlock(&instance->guard);
    147                 return ENOENT;
    148         }
    149         /* Already bound */
    150         if (instance->devices[address].handle != 0) {
    151                 fibril_mutex_unlock(&instance->guard);
    152                 return EEXISTS;
    153         }
    154         instance->devices[address].handle = handle;
    155121        fibril_mutex_unlock(&instance->guard);
    156122        return EOK;
     
    178144
    179145        instance->devices[address].occupied = false;
    180         instance->devices[address].handle = 0;
    181146        fibril_mutex_unlock(&instance->guard);
    182147        return EOK;
    183148}
    184149
    185 /** Find USB address associated with the device.
    186  *
    187  * @param[in] instance Device manager structure to use.
    188  * @param[in] handle Devman handle of the device seeking its address.
    189  * @return USB Address, or error code.
    190  */
    191 usb_address_t usb_device_manager_find_address(
    192     usb_device_manager_t *instance, devman_handle_t handle)
    193 {
    194         assert(instance);
    195         fibril_mutex_lock(&instance->guard);
    196         for (usb_address_t address = 1; address <= USB11_ADDRESS_MAX; ++address)
    197         {
    198                 if (instance->devices[address].handle == handle) {
    199                         assert(instance->devices[address].occupied);
    200                         fibril_mutex_unlock(&instance->guard);
    201                         return address;
    202                 }
    203         }
    204         fibril_mutex_unlock(&instance->guard);
    205         return ENOENT;
    206 }
    207 
    208 /** Find devman handle and speed assigned to USB address.
     150/** Get speed assigned to USB address.
    209151 *
    210152 * @param[in] instance Device manager structure to use.
    211153 * @param[in] address Address the caller wants to find.
    212  * @param[out] handle Where to store found handle.
    213154 * @param[out] speed Assigned speed.
    214155 * @return Error code.
    215156 */
    216157int usb_device_manager_get_info_by_address(usb_device_manager_t *instance,
    217     usb_address_t address, devman_handle_t *handle, usb_speed_t *speed)
     158    usb_address_t address, usb_speed_t *speed)
    218159{
    219160        assert(instance);
     
    228169        }
    229170
    230         if (handle != NULL) {
    231                 *handle = instance->devices[address].handle;
    232         }
    233171        if (speed != NULL) {
    234172                *speed = instance->devices[address].speed;
Note: See TracChangeset for help on using the changeset viewer.