Changeset 0918382f in mainline for uspace/lib
- Timestamp:
- 2013-08-07T15:00:36Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 14dd4c9
- Parents:
- 2757247
- Location:
- uspace/lib
- Files:
-
- 3 edited
-
drv/generic/remote_usb.c (modified) (4 diffs)
-
drv/include/usb_iface.h (modified) (3 diffs)
-
usbhost/src/ddf_helpers.c (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/remote_usb.c
r2757247 r0918382f 139 139 * @return Error code. 140 140 */ 141 int usb_device_enumerate(async_exch_t *exch, usb_device_handle_t *handle) 142 { 143 if (!exch || !handle) 144 return EBADMEM; 145 sysarg_t h; 146 const int ret = async_req_1_1(exch, DEV_IFACE_ID(USB_DEV_IFACE), 147 IPC_M_USB_DEVICE_ENUMERATE, &h); 148 if (ret == EOK) 149 *handle = (usb_device_handle_t)h; 141 int usb_device_enumerate(async_exch_t *exch, unsigned port) 142 { 143 if (!exch) 144 return EBADMEM; 145 const int ret = async_req_2_0(exch, DEV_IFACE_ID(USB_DEV_IFACE), 146 IPC_M_USB_DEVICE_ENUMERATE, port); 150 147 return ret; 151 148 } … … 156 153 * @return Error code. 157 154 */ 158 int usb_device_remove(async_exch_t *exch, u sb_device_handle_t handle)155 int usb_device_remove(async_exch_t *exch, unsigned port) 159 156 { 160 157 if (!exch) 161 158 return EBADMEM; 162 159 return async_req_2_0(exch, DEV_IFACE_ID(USB_DEV_IFACE), 163 IPC_M_USB_DEVICE_REMOVE, handle);160 IPC_M_USB_DEVICE_REMOVE, port); 164 161 } 165 162 … … 381 378 } 382 379 383 usb_device_handle_t handle = 0; 384 const int ret = usb_iface->device_enumerate(fun, &handle); 385 if (ret != EOK) { 386 async_answer_0(callid, ret); 387 } 388 389 async_answer_1(callid, EOK, (sysarg_t) handle); 380 const unsigned port = DEV_IPC_GET_ARG1(*call); 381 const int ret = usb_iface->device_enumerate(fun, port); 382 async_answer_0(callid, ret); 390 383 } 391 384 … … 400 393 } 401 394 402 usb_device_handle_t handle= DEV_IPC_GET_ARG1(*call);403 const int ret = usb_iface->device_remove(fun, handle);395 const unsigned port = DEV_IPC_GET_ARG1(*call); 396 const int ret = usb_iface->device_remove(fun, port); 404 397 async_answer_0(callid, ret); 405 398 } -
uspace/lib/drv/include/usb_iface.h
r2757247 r0918382f 42 42 #include <usb/usb.h> 43 43 44 typedef intptr_t usb_device_handle_t;45 enum {46 USB_DEVICE_HANDLE_INVALID = -147 };48 44 typedef async_sess_t usb_dev_session_t; 49 45 … … 58 54 int usb_release_default_address(async_exch_t *); 59 55 60 int usb_device_enumerate(async_exch_t *, u sb_device_handle_t *);61 int usb_device_remove(async_exch_t *, u sb_device_handle_t);56 int usb_device_enumerate(async_exch_t *, unsigned port); 57 int usb_device_remove(async_exch_t *, unsigned port); 62 58 63 59 int usb_register_endpoint(async_exch_t *, usb_endpoint_t, usb_transfer_type_t, … … 81 77 int (*release_default_address)(ddf_fun_t *); 82 78 83 int (*device_enumerate)(ddf_fun_t *, u sb_device_handle_t *);84 int (*device_remove)(ddf_fun_t *, u sb_device_handle_t);79 int (*device_enumerate)(ddf_fun_t *, unsigned); 80 int (*device_remove)(ddf_fun_t *, unsigned); 85 81 86 82 int (*register_endpoint)(ddf_fun_t *, usb_endpoint_t, -
uspace/lib/usbhost/src/ddf_helpers.c
r2757247 r0918382f 77 77 } usb_dev_t; 78 78 79 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port, 80 usb_address_t *id); 81 static int hcd_ddf_remove_device(ddf_dev_t *device, usb_dev_t *hub, 82 usb_address_t id); 79 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port); 80 static int hcd_ddf_remove_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port); 83 81 84 82 … … 164 162 } 165 163 166 static int device_enumerate(ddf_fun_t *fun, u sb_device_handle_t *handle)164 static int device_enumerate(ddf_fun_t *fun, unsigned port) 167 165 { 168 166 assert(fun); … … 171 169 assert(ddf_dev); 172 170 assert(dev); 173 usb_address_t address = 0; 174 unsigned port = 0; //TODO provide real value here 175 usb_log_debug("Device %d reported a new USB device\n", dev->address); 176 const int ret = hcd_ddf_new_device(ddf_dev, dev, port, &address); 177 if (ret == EOK && handle) 178 *handle = address; 179 return ret; 180 } 181 182 static int device_remove(ddf_fun_t *fun, usb_device_handle_t handle) 171 usb_log_debug("Hub %d reported a new USB device on port: %u\n", 172 dev->address, port); 173 return hcd_ddf_new_device(ddf_dev, dev, port); 174 } 175 176 static int device_remove(ddf_fun_t *fun, unsigned port) 183 177 { 184 178 assert(fun); … … 187 181 assert(ddf_dev); 188 182 assert(dev); 189 usb_log_debug("Hub `%s' reported removal of device %d\n",190 ddf_fun_get_name(fun), (int)handle);191 return hcd_ddf_remove_device(ddf_dev, dev, (usb_address_t)handle);183 usb_log_debug("Hub `%s' reported removal of device on port %u\n", 184 ddf_fun_get_name(fun), port); 185 return hcd_ddf_remove_device(ddf_dev, dev, port); 192 186 } 193 187 … … 405 399 406 400 static int hcd_ddf_remove_device(ddf_dev_t *device, usb_dev_t *hub, 407 u sb_address_t id)401 unsigned port) 408 402 { 409 403 assert(device); … … 421 415 list_foreach(hub->devices, it) { 422 416 victim = list_get_instance(it, usb_dev_t, link); 423 if (victim-> address == id)417 if (victim->port == port) 424 418 break; 425 419 } 426 if (victim && victim-> address == id) {420 if (victim && victim->port == port) { 427 421 list_remove(&victim->link); 428 422 fibril_mutex_unlock(&hc_dev->guard); … … 432 426 hcd_release_address(hcd, victim->address); 433 427 } else { 434 usb_log_warning("Failed to unbind device %d: %s\n",435 id, str_error(ret));428 usb_log_warning("Failed to unbind device `%s': %s\n", 429 ddf_fun_get_name(victim->fun), str_error(ret)); 436 430 } 437 431 return EOK; … … 440 434 } 441 435 442 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port, 443 usb_address_t *id) 436 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port) 444 437 { 445 438 assert(device); … … 552 545 hcd_remove_ep(hcd, target, USB_DIRECTION_BOTH); 553 546 hcd_release_address(hcd, target.address); 554 return ret; 555 } 556 if (ret == EOK && id) 557 *id = target.address; 547 } 558 548 559 549 return ret; … … 574 564 575 565 hcd_reserve_default_address(hcd, speed); 576 const int ret = hcd_ddf_new_device(device, NULL, 0 , NULL);566 const int ret = hcd_ddf_new_device(device, NULL, 0); 577 567 hcd_release_default_address(hcd); 578 568 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.
