Changeset 8e4219ab in mainline for uspace/lib/usbdev/src/devdrv.c
- Timestamp:
- 2013-08-02T14:04:51Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6fe7683
- Parents:
- 9d15d1b
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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);
Note:
See TracChangeset
for help on using the changeset viewer.