Changeset b9d910f in mainline for uspace/drv/uhci-hcd/main.c
- Timestamp:
- 2011-02-19T23:02:49Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fb78ae72
- Parents:
- 6edc69a
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/main.c
r6edc69a rb9d910f 80 80 }; 81 81 /*----------------------------------------------------------------------------*/ 82 static irq_cmd_t uhci_cmds[] = {83 {84 .cmd = CMD_PIO_READ_16,85 .addr = (void*)0xc022,86 .dstarg = 187 },88 {89 .cmd = CMD_PIO_WRITE_16,90 .addr = (void*)0xc022,91 .value = 0x1f92 },93 {94 .cmd = CMD_ACCEPT95 }96 };97 /*----------------------------------------------------------------------------*/98 static irq_code_t uhci_code = {99 sizeof(uhci_cmds) / sizeof(irq_cmd_t),100 uhci_cmds101 };102 /*----------------------------------------------------------------------------*/103 82 static void irq_handler(device_t *device, ipc_callid_t iid, ipc_call_t *call) 104 83 { … … 111 90 } 112 91 /*----------------------------------------------------------------------------*/ 92 #define CHECK_RET_RETURN(ret, message...) \ 93 if (ret != EOK) { \ 94 usb_log_error(message); \ 95 return ret; \ 96 } 97 113 98 static int uhci_add_device(device_t *device) 114 99 { … … 125 110 pci_get_my_registers(device, &io_reg_base, &io_reg_size, &irq); 126 111 127 if (ret != EOK) { 128 usb_log_error( 129 "Failed(%d) to get I/O registers addresses for device:.\n", 130 ret, device->handle); 131 return ret; 132 } 133 112 CHECK_RET_RETURN(ret, 113 "Failed(%d) to get I/O registers addresses for device:.\n", 114 ret, device->handle); 134 115 usb_log_info("I/O regs at 0x%X (size %zu), IRQ %d.\n", 135 116 io_reg_base, io_reg_size, irq); … … 158 139 async_hangup(irc_phone); 159 140 160 ret = register_interrupt_handler(device, irq, irq_handler, &uhci_code);161 usb_log_debug("Registered interrupt handler %d.\n", ret);162 141 163 142 uhci_t *uhci_hc = malloc(sizeof(uhci_t)); 164 if (!uhci_hc) { 165 usb_log_error("Failed to allocate memory for uhci hcd driver.\n"); 166 return ENOMEM; 167 } 143 ret = (uhci_hc != NULL) ? EOK : ENOMEM; 144 CHECK_RET_RETURN(ret, "Failed to allocate memory for uhci hcd driver.\n"); 168 145 169 146 ret = uhci_init(uhci_hc, (void*)io_reg_base, io_reg_size); 170 147 if (ret != EOK) { 171 148 usb_log_error("Failed to init uhci-hcd.\n"); 149 free(uhci_hc); 172 150 return ret; 173 151 } 152 153 ret = register_interrupt_handler(device, irq, irq_handler, 154 &uhci_hc->interrupt_code); 155 if (ret != EOK) { 156 usb_log_error("Failed to register interrupt handler.\n"); 157 uhci_fini(uhci_hc); 158 free(uhci_hc); 159 return ret; 160 } 161 174 162 device_t *rh; 175 163 ret = setup_root_hub(&rh, device); 176 164 if (ret != EOK) { 177 165 usb_log_error("Failed to setup uhci root hub.\n"); 178 /* TODO: destroy uhci here */ 166 uhci_fini(uhci_hc); 167 free(uhci_hc); 179 168 return ret; 180 169 } … … 183 172 if (ret != EOK) { 184 173 usb_log_error("Failed to register root hub.\n"); 185 /* TODO: destroy uhci here */ 174 uhci_fini(uhci_hc); 175 free(uhci_hc); 176 free(rh); 186 177 return ret; 187 178 } 188 179 189 180 device->driver_data = uhci_hc; 190 191 181 return EOK; 192 182 }
Note:
See TracChangeset
for help on using the changeset viewer.