Changes in uspace/lib/usbhost/src/ddf_helpers.c [cccd60c3:68e5406] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/ddf_helpers.c
rcccd60c3 r68e5406 481 481 }}; 482 482 483 const usb_address_t address = hcd_request_address(hcd, speed); 484 if (address < 0) { 483 usb_address_t address; 484 ret = hcd_request_address(hcd, speed, &address); 485 if (ret != EOK) { 485 486 usb_log_error("Failed to reserve new address: %s.", 486 str_error( address));487 return address;487 str_error(ret)); 488 return ret; 488 489 } 489 490 … … 518 519 usb_log_debug("Device(%d): Requesting first 8B of device descriptor.", 519 520 address); 520 ssize_t got = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_IN, 521 size_t got; 522 ret = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_IN, 521 523 &desc, CTRL_PIPE_MIN_PACKET_SIZE, *(uint64_t *)&get_device_desc_8, 522 "read first 8 bytes of dev descriptor"); 523 524 if (got != CTRL_PIPE_MIN_PACKET_SIZE) { 525 ret = got < 0 ? got : EOVERFLOW; 524 "read first 8 bytes of dev descriptor", &got); 525 526 if (ret == EOK && got != CTRL_PIPE_MIN_PACKET_SIZE) { 527 ret = EOVERFLOW; 528 } 529 530 if (ret != EOK) { 526 531 usb_log_error("Device(%d): Failed to get 8B of dev descr: %s.", 527 532 address, str_error(ret)); … … 552 557 553 558 usb_log_debug("Device(%d): Setting USB address.", address); 554 got = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_OUT,555 NULL, 0, *(uint64_t *)&set_address, "set address" );559 ret = hcd_send_batch_sync(hcd, default_target, USB_DIRECTION_OUT, 560 NULL, 0, *(uint64_t *)&set_address, "set address", &got); 556 561 557 562 usb_log_debug("Device(%d): Removing default (0:0) EP.", address); 558 563 hcd_remove_ep(hcd, default_target, USB_DIRECTION_BOTH); 559 564 560 if ( got != 0) {565 if (ret != EOK) { 561 566 usb_log_error("Device(%d): Failed to set new address: %s.", 562 address, str_error( got));567 address, str_error(ret)); 563 568 hcd_remove_ep(hcd, target, USB_DIRECTION_BOTH); 564 569 hcd_release_address(hcd, address); 565 return got;570 return ret; 566 571 } 567 572 … … 572 577 usb_log_debug("Device(%d): Requesting full device descriptor.", 573 578 address); 574 got = hcd_send_batch_sync(hcd, target, USB_DIRECTION_IN,579 ret = hcd_send_batch_sync(hcd, target, USB_DIRECTION_IN, 575 580 &desc, sizeof(desc), *(uint64_t *)&get_device_desc, 576 "read device descriptor" );581 "read device descriptor", &got); 577 582 if (ret != EOK) { 578 583 usb_log_error("Device(%d): Failed to set get dev descriptor: %s", … … 742 747 * @param[in] gen_irq_code IRQ code generator. 743 748 * 744 * @return IRQ capability handle on success. 745 * @return Negative error code. 749 * @param[out] handle IRQ capability handle on success. 750 * 751 * @return Error code. 746 752 */ 747 753 int hcd_ddf_setup_interrupts(ddf_dev_t *device, 748 754 const hw_res_list_parsed_t *hw_res, 749 755 interrupt_handler_t handler, 750 int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *hw_res)) 756 int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *, int *), 757 cap_handle_t *handle) 751 758 { 752 759 … … 757 764 irq_code_t irq_code = {0}; 758 765 759 const int irq = gen_irq_code(&irq_code, hw_res); 760 if (irq < 0) { 766 int irq; 767 int ret = gen_irq_code(&irq_code, hw_res, &irq); 768 if (ret != EOK) { 761 769 usb_log_error("Failed to generate IRQ code: %s.\n", 762 str_error( irq));763 return irq;770 str_error(ret)); 771 return ret; 764 772 } 765 773 766 774 /* Register handler to avoid interrupt lockup */ 767 const int irq_cap= register_interrupt_handler(device, irq, handler,768 &irq_code );775 ret = register_interrupt_handler(device, irq, handler, 776 &irq_code, handle); 769 777 irq_code_clean(&irq_code); 770 if (irq_cap < 0) {771 usb_log_error("Failed to register interrupt handler: %s.\n",772 str_error(irq_cap));773 return irq_cap;774 }775 776 /* Enable interrupts */777 int ret = hcd_ddf_enable_interrupt(device, irq);778 778 if (ret != EOK) { 779 779 usb_log_error("Failed to register interrupt handler: %s.\n", 780 780 str_error(ret)); 781 unregister_interrupt_handler(device, irq_cap); 782 return ret; 783 } 784 return irq_cap; 781 return ret; 782 } 783 784 /* Enable interrupts */ 785 ret = hcd_ddf_enable_interrupt(device, irq); 786 if (ret != EOK) { 787 usb_log_error("Failed to register interrupt handler: %s.\n", 788 str_error(ret)); 789 unregister_interrupt_handler(device, *handle); 790 } 791 return ret; 785 792 } 786 793 … … 788 795 * 789 796 * @param[in] dev DDF instance of the device to use. 790 * @param[in] iid (Unused).791 797 * @param[in] call Pointer to the call from kernel. 792 798 */ 793 void ddf_hcd_gen_irq_handler(ipc_call id_t iid, ipc_call_t *call, ddf_dev_t *dev)799 void ddf_hcd_gen_irq_handler(ipc_call_t *call, ddf_dev_t *dev) 794 800 { 795 801 assert(dev); … … 877 883 interrupt_handler_t *irq_handler = 878 884 driver->irq_handler ? driver->irq_handler : ddf_hcd_gen_irq_handler; 879 const int irq_cap = hcd_ddf_setup_interrupts(device, &hw_res, 880 irq_handler, driver->irq_code_gen); 881 bool irqs_enabled = !(irq_cap < 0); 885 int irq_cap; 886 ret = hcd_ddf_setup_interrupts(device, &hw_res, 887 irq_handler, driver->irq_code_gen, &irq_cap); 888 bool irqs_enabled = (ret == EOK); 882 889 if (irqs_enabled) { 883 890 usb_log_debug("Hw interrupts enabled.\n"); 884 891 } 885 892 886 if (driver->claim) 893 if (driver->claim) { 887 894 ret = driver->claim(device); 888 if (ret != EOK) { 889 usb_log_error("Failed to claim `%s' for driver `%s'", 890 ddf_dev_get_name(device), driver->name); 891 return ret; 895 if (ret != EOK) { 896 usb_log_error("Failed to claim `%s' for driver `%s'", 897 ddf_dev_get_name(device), driver->name); 898 return ret; 899 } 892 900 } 893 901
Note:
See TracChangeset
for help on using the changeset viewer.