Changeset 8e4219ab in mainline
- Timestamp:
- 2013-08-02T14:04:51Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6fe7683
- Parents:
- 9d15d1b
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/usbmid.c
r9d15d1b r8e4219ab 59 59 } 60 60 61 static int usb_iface_device_handle(ddf_fun_t *fun, devman_handle_t *handle) 62 { 63 assert(fun); 64 assert(handle); 65 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 66 assert(usb_dev); 67 *handle = usb_device_get_devman_handle(usb_dev); 68 return EOK; 69 } 70 61 71 /** Get USB device address by calling the parent usb_device_t. 62 72 * … … 119 129 .get_hc_handle = usb_iface_device_hc_handle, 120 130 .get_my_address = usb_iface_device_address, 131 .get_device_handle = usb_iface_device_handle, 121 132 .get_my_interface = usb_iface_iface, 122 133 .register_endpoint = usb_iface_register_endpoint, -
uspace/lib/usbdev/include/usb/dev/device.h
r9d15d1b r8e4219ab 62 62 } 63 63 64 65 64 usb_device_t * usb_device_create(devman_handle_t); 66 65 void usb_device_destroy(usb_device_t *); … … 86 85 87 86 int usb_device_get_iface_number(usb_device_t *); 87 devman_handle_t usb_device_get_devman_handle(usb_device_t *); 88 88 89 89 const usb_device_descriptors_t * usb_device_descriptors(usb_device_t *); -
uspace/lib/usbdev/src/devdrv.c
r9d15d1b r8e4219ab 78 78 void *driver_data; 79 79 80 /** Connection to device on USB bus */ 80 81 usb_dev_session_t *bus_session; 82 /** devman handle */ 83 devman_handle_t handle; 81 84 } usb_device_t; 82 85 … … 331 334 } 332 335 336 devman_handle_t usb_device_get_devman_handle(usb_device_t *usb_dev) 337 { 338 assert(usb_dev); 339 return usb_dev->handle; 340 } 341 333 342 const usb_device_descriptors_t *usb_device_descriptors(usb_device_t *usb_dev) 334 343 { … … 405 414 static int usb_device_init(usb_device_t *usb_dev, ddf_dev_t *ddf_dev, 406 415 const usb_endpoint_description_t **endpoints, const char **errstr_ptr, 407 devman_handle_t handle )416 devman_handle_t handle, int interface_no) 408 417 { 409 418 assert(usb_dev != NULL); … … 413 422 414 423 usb_dev->ddf_dev = ddf_dev; 424 usb_dev->handle = handle; 425 usb_dev->interface_no = interface_no; 415 426 usb_dev->driver_data = NULL; 416 427 usb_dev->descriptors.full_config = NULL; … … 419 430 usb_dev->pipes = NULL; 420 431 421 if (ddf_dev) 422 usb_dev->bus_session = usb_dev_connect_to_self(ddf_dev); 423 else 424 usb_dev->bus_session = usb_dev_connect(handle); 432 usb_dev->bus_session = usb_dev_connect(handle); 425 433 426 434 if (!usb_dev->bus_session) { … … 433 441 usb_address_t address; 434 442 435 int rc = usb_dev_get_info(usb_dev, 436 &hc_handle, &address, &usb_dev->interface_no); 443 int rc = usb_dev_get_info(usb_dev, &hc_handle, &address, NULL); 437 444 if (rc != EOK) { 438 445 usb_dev_disconnect(usb_dev->bus_session); … … 503 510 } 504 511 512 static int usb_device_get_info(async_sess_t *sess, devman_handle_t *handle, 513 int *iface_no) 514 { 515 assert(handle); 516 assert(iface_no); 517 async_exch_t *exch = async_exchange_begin(sess); 518 if (!exch) 519 return EPARTY; 520 int ret = usb_get_device_handle(exch, handle); 521 if (ret == EOK) { 522 ret = usb_get_my_interface(exch, iface_no); 523 if (ret == ENOTSUP) { 524 *iface_no = -1; 525 ret = EOK; 526 } 527 } 528 async_exchange_end(exch); 529 return ret; 530 } 531 505 532 int usb_device_create_ddf(ddf_dev_t *ddf_dev, 506 533 const usb_endpoint_description_t **desc, const char **err) … … 508 535 assert(ddf_dev); 509 536 assert(err); 537 538 devman_handle_t h = 0; 539 int iface_no = -1; 540 541 async_sess_t *sess = devman_parent_device_connect(EXCHANGE_ATOMIC, 542 ddf_dev_get_handle(ddf_dev), IPC_FLAG_BLOCKING); 543 const int ret = usb_device_get_info(sess, &h, &iface_no); 544 async_hangup(sess); 545 if (ret != EOK) 546 return ret; 547 510 548 usb_device_t *usb_dev = 511 549 ddf_dev_data_alloc(ddf_dev, sizeof(usb_device_t)); … … 514 552 return ENOMEM; 515 553 } 516 return usb_device_init(usb_dev, ddf_dev, desc, err, 0); 554 555 return usb_device_init(usb_dev, ddf_dev, desc, err, h, iface_no); 517 556 } 518 557 … … 528 567 usb_device_t * usb_device_create(devman_handle_t handle) 529 568 { 569 devman_handle_t h = 0; 570 int iface_no = -1; 571 572 async_sess_t *sess = devman_device_connect( 573 EXCHANGE_ATOMIC, handle, IPC_FLAG_BLOCKING); 574 int ret = usb_device_get_info(sess, &h, &iface_no); 575 async_hangup(sess); 576 if (ret != EOK) 577 return NULL; 578 530 579 usb_device_t *usb_dev = malloc(sizeof(usb_device_t)); 531 580 if (!usb_dev) 532 581 return NULL; 582 533 583 const char* dummy = NULL; 534 const int ret = usb_device_init(usb_dev, NULL, NULL, &dummy, handle);584 ret = usb_device_init(usb_dev, NULL, NULL, &dummy, handle, iface_no); 535 585 if (ret != EOK) { 536 586 free(usb_dev); -
uspace/lib/usbhost/src/ddf_helpers.c
r9d15d1b r8e4219ab 216 216 } 217 217 218 /** Gets handle of the respective hc (this device, hc function). 219 * 220 * @param[in] root_hub_fun Root hub function seeking hc handle. 221 * @param[out] handle Place to write the handle. 222 * @return Error code. 223 */ 224 static int get_device_handle(ddf_fun_t *fun, devman_handle_t *handle) 225 { 226 assert(fun); 227 if (handle) 228 *handle = ddf_fun_get_handle(fun); 229 return EOK; 230 } 231 218 232 /** Root hub USB interface */ 219 233 static usb_iface_t usb_iface = { 220 234 .get_hc_handle = get_hc_handle, 221 235 .get_my_address = get_my_address, 236 237 .get_device_handle = get_device_handle, 222 238 223 239 .reserve_default_address = reserve_default_address, … … 228 244 .unregister_endpoint = unregister_endpoint, 229 245 }; 230 /** Standard USB RH options (RH interface) */ 246 247 /** Standard USB RH options (device interface) */ 231 248 static ddf_dev_ops_t usb_ops = { 232 249 .interfaces[USB_DEV_IFACE] = &usb_iface,
Note:
See TracChangeset
for help on using the changeset viewer.