Changes in uspace/drv/bus/usb/uhci/uhci.c [fc6e607:5203e256] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/uhci.c
rfc6e607 r5203e256 64 64 { 65 65 assert(dev); 66 assert(dev->driver_data); 66 67 return dev->driver_data; 67 68 } … … 77 78 assert(dev); 78 79 uhci_t *uhci = dev_to_uhci(dev); 79 if (!uhci) { 80 usb_log_error("Interrupt on not yet initialized device.\n"); 81 return; 82 } 80 hc_t *hc = &uhci->hc; 83 81 const uint16_t status = IPC_GET_ARG1(*call); 84 hc_interrupt(&uhci->hc, status); 82 assert(hc); 83 hc_interrupt(hc, status); 85 84 } 86 85 /*----------------------------------------------------------------------------*/ … … 193 192 } \ 194 193 free(instance); \ 195 device->driver_data = NULL; \196 194 usb_log_error(message); \ 197 195 return ret; \ … … 224 222 ret = pci_disable_legacy(device); 225 223 CHECK_RET_DEST_FREE_RETURN(ret, 226 "Failed to disable legacy USB: %s.\n", str_error(ret)); 227 228 const size_t cmd_count = hc_irq_cmd_count(); 229 irq_cmd_t irq_cmds[cmd_count]; 230 ret = 231 hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size); 232 CHECK_RET_DEST_FREE_RETURN(ret, 233 "Failed to generate IRQ commands: %s.\n", str_error(ret)); 234 235 irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds }; 236 237 /* Register handler to avoid interrupt lockup */ 238 ret = register_interrupt_handler(device, irq, irq_handler, &irq_code); 239 CHECK_RET_DEST_FREE_RETURN(ret, 240 "Failed to register interrupt handler: %s.\n", str_error(ret)); 224 "Failed(%d) to disable legacy USB: %s.\n", ret, str_error(ret)); 241 225 242 226 bool interrupts = false; 227 #ifdef CONFIG_USBHC_NO_INTERRUPTS 228 usb_log_warning("Interrupts disabled in OS config, " \ 229 "falling back to polling.\n"); 230 #else 243 231 ret = pci_enable_interrupts(device); 244 232 if (ret != EOK) { 245 usb_log_warning("Failed to enable interrupts: %s." 246 " Falling back to polling.\n", str_error(ret)); 233 usb_log_warning("Failed to enable interrupts: %s.\n", 234 str_error(ret)); 235 usb_log_info("HW interrupts not available, " \ 236 "falling back to polling.\n"); 247 237 } else { 248 238 usb_log_debug("Hw interrupts enabled.\n"); 249 239 interrupts = true; 250 240 } 241 #endif 242 251 243 252 244 ret = hc_init(&instance->hc, (void*)reg_base, reg_size, interrupts); 253 245 CHECK_RET_DEST_FREE_RETURN(ret, 254 "Failed to init uhci_hcd: %s.\n", str_error(ret)); 255 256 device->driver_data = instance; 246 "Failed(%d) to init uhci_hcd: %s.\n", ret, str_error(ret)); 257 247 258 248 #define CHECK_RET_FINI_RETURN(ret, message...) \ … … 263 253 } else (void)0 264 254 255 /* It does no harm if we register this on polling */ 256 ret = register_interrupt_handler(device, irq, irq_handler, 257 &instance->hc.interrupt_code); 258 CHECK_RET_FINI_RETURN(ret, 259 "Failed(%d) to register interrupt handler: %s.\n", 260 ret, str_error(ret)); 261 265 262 ret = ddf_fun_bind(instance->hc_fun); 266 CHECK_RET_FINI_RETURN(ret, "Failed to bind UHCI device function: %s.\n", 267 str_error(ret)); 263 CHECK_RET_FINI_RETURN(ret, 264 "Failed(%d) to bind UHCI device function: %s.\n", 265 ret, str_error(ret)); 268 266 269 267 ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME); … … 274 272 (uintptr_t)instance->hc.registers + 0x10, 4); 275 273 CHECK_RET_FINI_RETURN(ret, 276 "Failed to setup UHCI root hub: %s.\n", str_error(ret));274 "Failed(%d) to setup UHCI root hub: %s.\n", ret, str_error(ret)); 277 275 278 276 ret = ddf_fun_bind(instance->rh_fun); 279 277 CHECK_RET_FINI_RETURN(ret, 280 "Failed to register UHCI root hub: %s.\n", str_error(ret)); 281 278 "Failed(%d) to register UHCI root hub: %s.\n", ret, str_error(ret)); 279 280 device->driver_data = instance; 282 281 return EOK; 283 282 #undef CHECK_RET_FINI_RETURN
Note:
See TracChangeset
for help on using the changeset viewer.