Changeset 0edf7c7 in mainline for uspace/lib/usb/src/hc.c
- Timestamp:
- 2011-05-20T20:01:25Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 04028225
- Parents:
- a60afd0
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/hc.c
ra60afd0 r0edf7c7 27 27 */ 28 28 29 /** @addtogroup libusb dev29 /** @addtogroup libusb 30 30 * @{ 31 31 */ 32 32 /** @file 33 * General communication between device drivers and host controller driver.33 * General communication with host controller driver (implementation). 34 34 */ 35 35 #include <devman.h> 36 36 #include <async.h> 37 #include <dev_iface.h> 37 38 #include <usb_iface.h> 38 #include <usb/dev/hc.h> 39 #include <usbhc_iface.h> 40 #include <usb/hc.h> 39 41 #include <usb/driver.h> 40 42 #include <usb/debug.h> … … 143 145 } 144 146 147 /** Get handle of USB device with given address. 148 * 149 * @param[in] connection Opened connection to host controller. 150 * @param[in] address Address of device in question. 151 * @param[out] handle Where to write the device handle. 152 * @return Error code. 153 */ 154 int usb_hc_get_handle_by_address(usb_hc_connection_t *connection, 155 usb_address_t address, devman_handle_t *handle) 156 { 157 if (!usb_hc_connection_is_opened(connection)) { 158 return ENOENT; 159 } 160 161 sysarg_t tmp; 162 int rc = async_req_2_1(connection->hc_phone, 163 DEV_IFACE_ID(USBHC_DEV_IFACE), 164 IPC_M_USBHC_GET_HANDLE_BY_ADDRESS, 165 address, &tmp); 166 if ((rc == EOK) && (handle != NULL)) { 167 *handle = tmp; 168 } 169 170 return rc; 171 } 172 173 174 /** Get host controller handle by its class index. 175 * 176 * @param class_index Class index for the host controller. 177 * @param hc_handle Where to store the HC handle 178 * (can be NULL for existence test only). 179 * @return Error code. 180 */ 181 int usb_ddf_get_hc_handle_by_class(size_t class_index, 182 devman_handle_t *hc_handle) 183 { 184 char *class_index_str; 185 devman_handle_t hc_handle_tmp; 186 int rc; 187 188 rc = asprintf(&class_index_str, "%zu", class_index); 189 if (rc < 0) { 190 return ENOMEM; 191 } 192 rc = devman_device_get_handle_by_class("usbhc", class_index_str, 193 &hc_handle_tmp, 0); 194 free(class_index_str); 195 if (rc != EOK) { 196 return rc; 197 } 198 199 if (hc_handle != NULL) { 200 *hc_handle = hc_handle_tmp; 201 } 202 203 return EOK; 204 } 205 145 206 /** 146 207 * @}
Note:
See TracChangeset
for help on using the changeset viewer.