Changeset 19d21728 in mainline
- Timestamp:
- 2013-09-21T05:22:21Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 772a172
- Parents:
- 6210a333
- Location:
- uspace/lib/usbhost
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
r6210a333 r19d21728 37 37 #define LIBUSBHOST_HOST_DDF_HELPERS_H 38 38 39 #include <ddf/interrupt.h> 39 40 #include <device/hw_res_parsed.h> 40 41 #include <usb/host/hcd.h> … … 50 51 int hcd_ddf_enable_interrupts(ddf_dev_t *device); 51 52 int hcd_ddf_get_registers(ddf_dev_t *device, hw_res_list_parsed_t *hw_res); 53 int hcd_ddf_setup_interrupts(ddf_dev_t *device, addr_range_t *regs, int irq, 54 interrupt_handler_t handler, int (*gen_irq_code)(irq_code_t *, addr_range_t *)); 52 55 53 56 #endif -
uspace/lib/usbhost/src/ddf_helpers.c
r6210a333 r19d21728 676 676 return ret; 677 677 } 678 679 // TODO: move this someplace else 680 static inline void irq_code_clean(irq_code_t *code) 681 { 682 if (code) { 683 free(code->ranges); 684 free(code->cmds); 685 code->ranges = NULL; 686 code->cmds = NULL; 687 code->rangecount = 0; 688 code->cmdcount = 0; 689 } 690 } 691 692 693 /** Register interrupt handler 694 * 695 * @param[in] device Host controller DDF device 696 * @param[in] regs Register range 697 * @param[in] irq Interrupt number 698 * @paran[in] handler Interrupt handler 699 * @param[in] gen_irq_code IRQ code generator. 700 * 701 * @return EOK on success or negative error code 702 */ 703 int hcd_ddf_setup_interrupts(ddf_dev_t *device, addr_range_t *regs, int irq, 704 interrupt_handler_t handler, 705 int (*gen_irq_code)(irq_code_t *, addr_range_t *)) 706 { 707 708 assert(device); 709 assert(regs); 710 assert(handler); 711 assert(gen_irq_code); 712 713 714 irq_code_t irq_code = {0}; 715 716 int ret = gen_irq_code(&irq_code, regs); 717 if (ret != EOK) { 718 usb_log_error("Failed to generate IRQ code: %s.\n", 719 str_error(ret)); 720 return ret; 721 } 722 723 /* Register handler to avoid interrupt lockup */ 724 ret = register_interrupt_handler(device, irq, handler, &irq_code); 725 irq_code_clean(&irq_code); 726 if (ret != EOK) { 727 usb_log_error("Failed to register interrupt handler: %s.\n", 728 str_error(ret)); 729 return ret; 730 } 731 732 /* Enable interrupts */ 733 ret = hcd_ddf_enable_interrupts(device); 734 if (ret != EOK) { 735 usb_log_error("Failed to register interrupt handler: %s.\n", 736 str_error(ret)); 737 unregister_interrupt_handler(device, irq); 738 return ret; 739 } 740 741 return EOK; 742 } 678 743 /** 679 744 * @}
Note:
See TracChangeset
for help on using the changeset viewer.