Changes in uspace/drv/bus/usb/ohci/pci.c [8f5b4d44:9b8958b] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/ohci/pci.c
r8f5b4d44 r9b8958b 42 42 #include <ddi.h> 43 43 #include <libarch/ddi.h> 44 #include <device/hw_res _parsed.h>44 #include <device/hw_res.h> 45 45 46 46 #include <usb/debug.h> … … 61 61 { 62 62 assert(dev); 63 assert(mem_reg_address); 64 assert(mem_reg_size); 65 assert(irq_no); 63 66 64 67 async_sess_t *parent_sess = … … 68 71 return ENOMEM; 69 72 70 hw_res_list_parsed_t hw_res; 71 hw_res_list_parsed_init(&hw_res); 72 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0); 73 hw_resource_list_t hw_resources; 74 int rc = hw_res_get_resource_list(parent_sess, &hw_resources); 73 75 async_hangup(parent_sess); 74 if (r et!= EOK) {75 return r et;76 if (rc != EOK) { 77 return rc; 76 78 } 77 79 78 /* We want one irq and one mem range. */ 79 if (hw_res.irqs.count != 1 || hw_res.mem_ranges.count != 1) { 80 hw_res_list_parsed_clean(&hw_res); 81 return EINVAL; 80 uintptr_t mem_address = 0; 81 size_t mem_size = 0; 82 bool mem_found = false; 83 84 int irq = 0; 85 bool irq_found = false; 86 87 for (size_t i = 0; i < hw_resources.count; i++) { 88 hw_resource_t *res = &hw_resources.resources[i]; 89 switch (res->type) { 90 case INTERRUPT: 91 irq = res->res.interrupt.irq; 92 irq_found = true; 93 usb_log_debug2("Found interrupt: %d.\n", irq); 94 break; 95 case MEM_RANGE: 96 if (res->res.mem_range.address != 0 97 && res->res.mem_range.size != 0 ) { 98 mem_address = res->res.mem_range.address; 99 mem_size = res->res.mem_range.size; 100 usb_log_debug2("Found mem: %p %zu.\n", 101 (void *) mem_address, mem_size); 102 mem_found = true; 103 } 104 default: 105 break; 106 } 82 107 } 108 free(hw_resources.resources); 83 109 84 if (mem_reg_address) 85 *mem_reg_address = hw_res.mem_ranges.ranges[0].address; 86 if (mem_reg_size) 87 *mem_reg_size = hw_res.mem_ranges.ranges[0].size; 88 if (irq_no) 89 *irq_no = hw_res.irqs.irqs[0]; 90 91 hw_res_list_parsed_clean(&hw_res); 92 return EOK; 110 if (mem_found && irq_found) { 111 *mem_reg_address = mem_address; 112 *mem_reg_size = mem_size; 113 *irq_no = irq; 114 return EOK; 115 } 116 return ENOENT; 93 117 } 94 118
Note:
See TracChangeset
for help on using the changeset viewer.