Changeset 059d507 in mainline


Ignore:
Timestamp:
2013-07-26T13:40:58Z (11 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.

Location:
uspace/lib/usbhost
Files:
4 edited

Legend:

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

    rb0fc92c r059d507  
    5757                usb_speed_t speed;      /**< Device speed */
    5858                bool occupied;          /**< The address is in use. */
    59                 devman_handle_t handle; /**< Devman handle of the device. */
    6059        } devices[USB_ADDRESS_COUNT];
    6160        /** Maximum speed allowed. */
     
    7372    usb_address_t *address, bool strict, usb_speed_t speed);
    7473
    75 int usb_device_manager_bind_address(usb_device_manager_t *instance,
    76     usb_address_t address, devman_handle_t handle);
    77 
    7874int usb_device_manager_release_address(usb_device_manager_t *instance,
    7975    usb_address_t address);
    8076
    81 usb_address_t usb_device_manager_find_address(usb_device_manager_t *instance,
    82     devman_handle_t handle);
    83 
    8477int usb_device_manager_get_info_by_address(usb_device_manager_t *instance,
    85     usb_address_t address, devman_handle_t *handle, usb_speed_t *speed);
     78    usb_address_t address, usb_speed_t *speed);
    8679#endif
    8780/**
  • uspace/lib/usbhost/src/ddf_helpers.c

    rb0fc92c r059d507  
    301301                return ret;
    302302        }
    303 
    304         ret = usb_device_manager_bind_address(&dev_to_hcd(parent)->dev_manager,
    305             address, ddf_fun_get_handle(fun));
    306         if (ret != EOK)
    307                 usb_log_warning("Failed to bind address: %s.\n",
    308                     str_error(ret));
    309303
    310304        list_append(&info->link, &hc_dev->devices);
     
    408402        /* This checks whether the default address is reserved and gets speed */
    409403        int ret = usb_device_manager_get_info_by_address(&hcd->dev_manager,
    410                 USB_ADDRESS_DEFAULT, NULL, &speed);
     404                USB_ADDRESS_DEFAULT, &speed);
    411405        if (ret != EOK) {
    412406                return ret;
  • uspace/lib/usbhost/src/hcd.c

    rb0fc92c r059d507  
    138138        usb_speed_t speed = USB_SPEED_MAX;
    139139        const int ret = usb_device_manager_get_info_by_address(
    140             &hcd->dev_manager, target.address, NULL, &speed);
     140            &hcd->dev_manager, target.address, &speed);
    141141        if (ret != EOK) {
    142142                return ret;
  • 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.