Changeset 64639256 in mainline for uspace/drv/bus/usb/uhci/uhci.c


Ignore:
Timestamp:
2011-07-17T09:56:53Z (13 years ago)
Author:
Petr Koupy <petr.koupy@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
df0956ee
Parents:
04b3c8c (diff), 4069f5c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge libposix changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/uhci.c

    r04b3c8c r64639256  
    6464{
    6565        assert(dev);
    66         assert(dev->driver_data);
    6766        return dev->driver_data;
    6867}
     
    7877        assert(dev);
    7978        uhci_t *uhci = dev_to_uhci(dev);
    80         hc_t *hc = &uhci->hc;
     79        if (!uhci) {
     80                usb_log_error("Interrupt on not yet initialized device.\n");
     81                return;
     82        }
    8183        const uint16_t status = IPC_GET_ARG1(*call);
    82         assert(hc);
    83         hc_interrupt(hc, status);
     84        hc_interrupt(&uhci->hc, status);
    8485}
    8586/*----------------------------------------------------------------------------*/
     
    192193        } \
    193194        free(instance); \
     195        device->driver_data = NULL; \
    194196        usb_log_error(message); \
    195197        return ret; \
     
    222224        ret = pci_disable_legacy(device);
    223225        CHECK_RET_DEST_FREE_RETURN(ret,
    224             "Failed(%d) to disable legacy USB: %s.\n", ret, str_error(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));
    225241
    226242        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
    231243        ret = pci_enable_interrupts(device);
    232244        if (ret != EOK) {
    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");
     245                usb_log_warning("Failed to enable interrupts: %s."
     246                    " Falling back to polling.\n", str_error(ret));
    237247        } else {
    238248                usb_log_debug("Hw interrupts enabled.\n");
    239249                interrupts = true;
    240250        }
    241 #endif
    242 
    243251
    244252        ret = hc_init(&instance->hc, (void*)reg_base, reg_size, interrupts);
    245253        CHECK_RET_DEST_FREE_RETURN(ret,
    246             "Failed(%d) to init uhci_hcd: %s.\n", ret, str_error(ret));
     254            "Failed to init uhci_hcd: %s.\n", str_error(ret));
     255
     256        device->driver_data = instance;
    247257
    248258#define CHECK_RET_FINI_RETURN(ret, message...) \
     
    253263} else (void)0
    254264
    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 
    262265        ret = ddf_fun_bind(instance->hc_fun);
    263         CHECK_RET_FINI_RETURN(ret,
    264             "Failed(%d) to bind UHCI device function: %s.\n",
    265             ret, str_error(ret));
     266        CHECK_RET_FINI_RETURN(ret, "Failed to bind UHCI device function: %s.\n",
     267            str_error(ret));
    266268
    267269        ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME);
     
    272274            (uintptr_t)instance->hc.registers + 0x10, 4);
    273275        CHECK_RET_FINI_RETURN(ret,
    274             "Failed(%d) to setup UHCI root hub: %s.\n", ret, str_error(ret));
     276            "Failed to setup UHCI root hub: %s.\n", str_error(ret));
    275277
    276278        ret = ddf_fun_bind(instance->rh_fun);
    277279        CHECK_RET_FINI_RETURN(ret,
    278             "Failed(%d) to register UHCI root hub: %s.\n", ret, str_error(ret));
    279 
    280         device->driver_data = instance;
     280            "Failed to register UHCI root hub: %s.\n", str_error(ret));
     281
    281282        return EOK;
    282283#undef CHECK_RET_FINI_RETURN
Note: See TracChangeset for help on using the changeset viewer.