Changeset f29643d5 in mainline
- Timestamp:
- 2015-07-05T09:25:02Z (9 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ff0258f
- Parents:
- f523daf
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/ddf_helpers.c
rf523daf rf29643d5 470 470 int ret = usb_bus_get_speed(&hcd->bus, USB_ADDRESS_DEFAULT, &speed); 471 471 if (ret != EOK) { 472 return ret; 473 } 474 475 usb_log_debug("Found new %s speed USB device\n", usb_str_speed(speed)); 472 usb_log_error("Failed to verify speed: %s.", str_error(ret)); 473 return ret; 474 } 475 476 usb_log_debug("Found new %s speed USB device.", usb_str_speed(speed)); 476 477 477 478 static const usb_target_t default_target = {{ … … 481 482 482 483 const usb_address_t address = hcd_request_address(hcd, speed); 483 if (address < 0) 484 if (address < 0) { 485 usb_log_error("Failed to reserve new address: %s.", 486 str_error(address)); 484 487 return address; 488 } 485 489 486 490 usb_log_debug("Reserved new address: %d\n", address); … … 500 504 tt_address, port); 501 505 if (ret != EOK) { 506 usb_log_error("Device(%d): Failed to add default target: %s.", 507 address, str_error(ret)); 502 508 hcd_release_address(hcd, address); 503 509 return ret; … … 510 516 511 517 // TODO CALLBACKS 512 usb_log_debug("Device(%d): Requesting first 8B of device descriptor \n",518 usb_log_debug("Device(%d): Requesting first 8B of device descriptor.", 513 519 address); 514 520 ssize_t got = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_IN, … … 517 523 518 524 if (got != CTRL_PIPE_MIN_PACKET_SIZE) { 525 ret = got < 0 ? got : EOVERFLOW; 526 usb_log_error("Device(%d): Failed to get 8B of dev descr: %s.", 527 address, str_error(ret)); 519 528 hcd_remove_ep(hcd, default_target, USB_DIRECTION_BOTH); 520 529 hcd_release_address(hcd, address); 521 return got < 0 ? got : EOVERFLOW;530 return ret; 522 531 } 523 532 524 533 /* Register EP on the new address */ 525 usb_log_debug("Device(%d): Registering control EP \n", address);534 usb_log_debug("Device(%d): Registering control EP.", address); 526 535 ret = hcd_add_ep(hcd, target, USB_DIRECTION_BOTH, USB_TRANSFER_CONTROL, 527 536 ED_MPS_PACKET_SIZE_GET(uint16_usb2host(desc.max_packet_size)), … … 530 539 tt_address, port); 531 540 if (ret != EOK) { 541 usb_log_error("Device(%d): Failed to register EP0: %s", 542 address, str_error(ret)); 532 543 hcd_remove_ep(hcd, default_target, USB_DIRECTION_BOTH); 533 544 hcd_remove_ep(hcd, target, USB_DIRECTION_BOTH); … … 540 551 SET_ADDRESS(target.address); 541 552 542 usb_log_debug("Device(%d): Setting USB address. \n", address);553 usb_log_debug("Device(%d): Setting USB address.", address); 543 554 got = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_OUT, 544 555 NULL, 0, *(uint64_t *)&set_address, "set address"); 545 556 546 usb_log_debug("Device(%d): Removing default (0:0) EP \n", address);557 usb_log_debug("Device(%d): Removing default (0:0) EP.", address); 547 558 hcd_remove_ep(hcd, default_target, USB_DIRECTION_BOTH); 548 559 549 560 if (got != 0) { 561 usb_log_error("Device(%d): Failed to set new address: %s.", 562 address, str_error(got)); 550 563 hcd_remove_ep(hcd, target, USB_DIRECTION_BOTH); 551 564 hcd_release_address(hcd, address); … … 557 570 GET_DEVICE_DESC(sizeof(desc)); 558 571 559 usb_log_debug("Device(%d): Requesting full device descriptor \n",572 usb_log_debug("Device(%d): Requesting full device descriptor.", 560 573 address); 561 574 got = hcd_send_batch_sync(hcd, target, USB_DIRECTION_IN, … … 563 576 "read device descriptor"); 564 577 if (ret != EOK) { 578 usb_log_error("Device(%d): Failed to set get dev descriptor: %s", 579 address, str_error(ret)); 565 580 hcd_remove_ep(hcd, target, USB_DIRECTION_BOTH); 566 581 hcd_release_address(hcd, target.address); 567 return got < 0 ? got : EOVERFLOW;582 return ret; 568 583 } 569 584 … … 572 587 init_match_ids(&mids); 573 588 574 usb_log_debug("Device(%d): Creating match IDs \n", address);589 usb_log_debug("Device(%d): Creating match IDs.", address); 575 590 ret = create_match_ids(&mids, &desc); 576 591 if (ret != EOK) { 592 usb_log_error("Device(%d): Failed to create match ids: %s", 593 address, str_error(ret)); 577 594 hcd_remove_ep(hcd, target, USB_DIRECTION_BOTH); 578 595 hcd_release_address(hcd, target.address); … … 581 598 582 599 /* Register device */ 583 usb_log_debug("Device(%d): Registering DDF device \n", address);600 usb_log_debug("Device(%d): Registering DDF device.", address); 584 601 ret = hcd_ddf_add_device(device, hub, port, address, speed, NULL, &mids); 585 602 clean_match_ids(&mids); 586 603 if (ret != EOK) { 604 usb_log_error("Device(%d): Failed to register: %s.", 605 address, str_error(ret)); 587 606 hcd_remove_ep(hcd, target, USB_DIRECTION_BOTH); 588 607 hcd_release_address(hcd, target.address); … … 844 863 } 845 864 846 if (driver->claim)847 ret = driver->claim(device);848 if (ret != EOK) {849 usb_log_error("Failed to claim `%s' for driver `%s'",850 ddf_dev_get_name(device), driver->name);851 return ret;852 }853 854 865 hw_res_list_parsed_t hw_res; 855 866 ret = hcd_ddf_get_registers(device, &hw_res); … … 875 886 usb_log_debug("Hw interrupts enabled.\n"); 876 887 } 888 889 if (driver->claim) 890 ret = driver->claim(device); 891 if (ret != EOK) { 892 usb_log_error("Failed to claim `%s' for driver `%s'", 893 ddf_dev_get_name(device), driver->name); 894 return ret; 895 } 896 877 897 878 898 /* Init hw driver */
Note:
See TracChangeset
for help on using the changeset viewer.