Changes in uspace/lib/usbhost/src/ddf_helpers.c [b7fd2a0:4547f11] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/ddf_helpers.c
rb7fd2a0 r4547f11 91 91 92 92 93 static errno_t hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port);94 static errno_t hcd_ddf_remove_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port);93 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port); 94 static int hcd_ddf_remove_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port); 95 95 96 96 … … 107 107 * @return Error code. 108 108 */ 109 static errno_t register_endpoint(109 static int register_endpoint( 110 110 ddf_fun_t *fun, usb_endpoint_t endpoint, 111 111 usb_transfer_type_t transfer_type, usb_direction_t direction, … … 136 136 * @return Error code. 137 137 */ 138 static errno_t unregister_endpoint(138 static int unregister_endpoint( 139 139 ddf_fun_t *fun, usb_endpoint_t endpoint, usb_direction_t direction) 140 140 { … … 151 151 } 152 152 153 static errno_t reserve_default_address(ddf_fun_t *fun, usb_speed_t speed)153 static int reserve_default_address(ddf_fun_t *fun, usb_speed_t speed) 154 154 { 155 155 assert(fun); … … 164 164 } 165 165 166 static errno_t release_default_address(ddf_fun_t *fun)166 static int release_default_address(ddf_fun_t *fun) 167 167 { 168 168 assert(fun); … … 176 176 } 177 177 178 static errno_t device_enumerate(ddf_fun_t *fun, unsigned port)178 static int device_enumerate(ddf_fun_t *fun, unsigned port) 179 179 { 180 180 assert(fun); … … 188 188 } 189 189 190 static errno_t device_remove(ddf_fun_t *fun, unsigned port)190 static int device_remove(ddf_fun_t *fun, unsigned port) 191 191 { 192 192 assert(fun); … … 206 206 * @return Error code. 207 207 */ 208 static errno_t get_my_device_handle(ddf_fun_t *fun, devman_handle_t *handle)208 static int get_my_device_handle(ddf_fun_t *fun, devman_handle_t *handle) 209 209 { 210 210 assert(fun); … … 224 224 * @return Error code. 225 225 */ 226 static errno_t dev_read(ddf_fun_t *fun, usb_endpoint_t endpoint,226 static int dev_read(ddf_fun_t *fun, usb_endpoint_t endpoint, 227 227 uint64_t setup_data, uint8_t *data, size_t size, 228 228 usbhc_iface_transfer_in_callback_t callback, void *arg) … … 250 250 * @return Error code. 251 251 */ 252 static errno_t dev_write(ddf_fun_t *fun, usb_endpoint_t endpoint,252 static int dev_write(ddf_fun_t *fun, usb_endpoint_t endpoint, 253 253 uint64_t setup_data, const uint8_t *data, size_t size, 254 254 usbhc_iface_transfer_out_callback_t callback, void *arg) … … 313 313 }; 314 314 315 static errno_t hcd_ddf_add_device(ddf_dev_t *parent, usb_dev_t *hub_dev,315 static int hcd_ddf_add_device(ddf_dev_t *parent, usb_dev_t *hub_dev, 316 316 unsigned port, usb_address_t address, usb_speed_t speed, const char *name, 317 317 const match_id_list_t *mids) … … 351 351 } 352 352 353 errno_t ret = ddf_fun_bind(fun);353 int ret = ddf_fun_bind(fun); 354 354 if (ret != EOK) { 355 355 ddf_fun_destroy(fun); … … 389 389 390 390 /* This is a copy of lib/usbdev/src/recognise.c */ 391 static errno_t create_match_ids(match_id_list_t *l,391 static int create_match_ids(match_id_list_t *l, 392 392 usb_standard_device_descriptor_t *d) 393 393 { … … 418 418 } 419 419 420 static errno_t hcd_ddf_remove_device(ddf_dev_t *device, usb_dev_t *hub,420 static int hcd_ddf_remove_device(ddf_dev_t *device, usb_dev_t *hub, 421 421 unsigned port) 422 422 { … … 443 443 list_remove(&victim->link); 444 444 fibril_mutex_unlock(&hub->guard); 445 const errno_t ret = ddf_fun_unbind(victim->fun);445 const int ret = ddf_fun_unbind(victim->fun); 446 446 if (ret == EOK) { 447 447 usb_address_t address = victim->address; … … 458 458 } 459 459 460 static errno_t hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port)460 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port) 461 461 { 462 462 assert(device); … … 468 468 469 469 /* This checks whether the default address is reserved and gets speed */ 470 errno_t ret = usb_bus_get_speed(&hcd->bus, USB_ADDRESS_DEFAULT, &speed);470 int ret = usb_bus_get_speed(&hcd->bus, USB_ADDRESS_DEFAULT, &speed); 471 471 if (ret != EOK) { 472 472 usb_log_error("Failed to verify speed: %s.", str_error(ret)); … … 621 621 * @return Error code 622 622 */ 623 errno_t hcd_ddf_setup_root_hub(ddf_dev_t *device)623 int hcd_ddf_setup_root_hub(ddf_dev_t *device) 624 624 { 625 625 assert(device); … … 628 628 629 629 hcd_reserve_default_address(hcd, hcd->bus.max_speed); 630 const errno_t ret = hcd_ddf_new_device(device, NULL, 0);630 const int ret = hcd_ddf_new_device(device, NULL, 0); 631 631 hcd_release_default_address(hcd); 632 632 return ret; … … 643 643 * This function does all the ddf work for hc driver. 644 644 */ 645 errno_t hcd_ddf_setup_hc(ddf_dev_t *device, usb_speed_t max_speed,645 int hcd_ddf_setup_hc(ddf_dev_t *device, usb_speed_t max_speed, 646 646 size_t bw, bw_count_func_t bw_count) 647 647 { … … 656 656 hcd_init(&instance->hcd, max_speed, bw, bw_count); 657 657 658 errno_t ret = ENOMEM;658 int ret = ENOMEM; 659 659 instance->ctl_fun = ddf_fun_create(device, fun_exposed, "ctl"); 660 660 if (!instance->ctl_fun) { … … 691 691 hc_dev_t *hc = dev_to_hc_dev(device); 692 692 assert(hc); 693 const errno_t ret = ddf_fun_unbind(hc->ctl_fun);693 const int ret = ddf_fun_unbind(hc->ctl_fun); 694 694 if (ret == EOK) 695 695 ddf_fun_destroy(hc->ctl_fun); … … 703 703 * @return Error code. 704 704 */ 705 errno_t hcd_ddf_enable_interrupt(ddf_dev_t *device, int inum)705 int hcd_ddf_enable_interrupt(ddf_dev_t *device, int inum) 706 706 { 707 707 async_sess_t *parent_sess = ddf_dev_parent_sess_get(device); … … 713 713 714 714 //TODO: Cache parent session in HCD 715 errno_t hcd_ddf_get_registers(ddf_dev_t *device, hw_res_list_parsed_t *hw_res)715 int hcd_ddf_get_registers(ddf_dev_t *device, hw_res_list_parsed_t *hw_res) 716 716 { 717 717 async_sess_t *parent_sess = ddf_dev_parent_sess_get(device); … … 720 720 721 721 hw_res_list_parsed_init(hw_res); 722 const errno_t ret = hw_res_get_list_parsed(parent_sess, hw_res, 0);722 const int ret = hw_res_get_list_parsed(parent_sess, hw_res, 0); 723 723 if (ret != EOK) 724 724 hw_res_list_parsed_clean(hw_res); … … 751 751 * @return Error code. 752 752 */ 753 errno_t hcd_ddf_setup_interrupts(ddf_dev_t *device,753 int hcd_ddf_setup_interrupts(ddf_dev_t *device, 754 754 const hw_res_list_parsed_t *hw_res, 755 755 interrupt_handler_t handler, 756 errno_t (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *, int *),756 int (*gen_irq_code)(irq_code_t *, const hw_res_list_parsed_t *, int *), 757 757 cap_handle_t *handle) 758 758 { … … 765 765 766 766 int irq; 767 errno_t ret = gen_irq_code(&irq_code, hw_res, &irq);767 int ret = gen_irq_code(&irq_code, hw_res, &irq); 768 768 if (ret != EOK) { 769 769 usb_log_error("Failed to generate IRQ code: %s.\n", … … 809 809 } 810 810 811 static errno_t interrupt_polling(void *arg)811 static int interrupt_polling(void *arg) 812 812 { 813 813 hcd_t *hcd = arg; … … 847 847 * - registers root hub 848 848 */ 849 errno_t hcd_ddf_add_hc(ddf_dev_t *device, const ddf_hc_driver_t *driver)849 int hcd_ddf_add_hc(ddf_dev_t *device, const ddf_hc_driver_t *driver) 850 850 { 851 851 assert(driver); … … 857 857 }; 858 858 859 errno_t ret = EOK;859 int ret = EOK; 860 860 const usb_speed_t speed = driver->hc_speed; 861 861 if (speed >= ARRAY_SIZE(bw) || bw[speed].bw == 0) { … … 884 884 driver->irq_handler ? driver->irq_handler : ddf_hcd_gen_irq_handler; 885 885 int irq_cap; 886 errno_t irq_ret = hcd_ddf_setup_interrupts(device, &hw_res,886 int irq_ret = hcd_ddf_setup_interrupts(device, &hw_res, 887 887 irq_handler, driver->irq_code_gen, &irq_cap); 888 888 bool irqs_enabled = (irq_ret == EOK);
Note:
See TracChangeset
for help on using the changeset viewer.