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


Ignore:
Timestamp:
2011-09-04T11:30:58Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
03bc76a
Parents:
d2c67e7 (diff), deac215e (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 mainline changes

File:
1 moved

Legend:

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

    rd2c67e7 r8ff0bd2  
    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/*----------------------------------------------------------------------------*/
     
    191192                ddf_fun_destroy(instance->rh_fun); \
    192193        } \
    193         free(instance); \
     194        device->driver_data = NULL; \
    194195        usb_log_error(message); \
    195196        return ret; \
     
    222223        ret = pci_disable_legacy(device);
    223224        CHECK_RET_DEST_FREE_RETURN(ret,
    224             "Failed(%d) to disable legacy USB: %s.\n", ret, str_error(ret));
     225            "Failed to disable legacy USB: %s.\n", str_error(ret));
     226
     227        const size_t cmd_count = hc_irq_cmd_count();
     228        irq_cmd_t irq_cmds[cmd_count];
     229        ret =
     230            hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size);
     231        CHECK_RET_DEST_FREE_RETURN(ret,
     232            "Failed to generate IRQ commands: %s.\n", str_error(ret));
     233
     234        irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds };
     235
     236        /* Register handler to avoid interrupt lockup */
     237        ret = register_interrupt_handler(device, irq, irq_handler, &irq_code);
     238        CHECK_RET_DEST_FREE_RETURN(ret,
     239            "Failed to register interrupt handler: %s.\n", str_error(ret));
    225240
    226241        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
    231242        ret = pci_enable_interrupts(device);
    232243        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");
     244                usb_log_warning("Failed to enable interrupts: %s."
     245                    " Falling back to polling.\n", str_error(ret));
    237246        } else {
    238247                usb_log_debug("Hw interrupts enabled.\n");
    239248                interrupts = true;
    240249        }
    241 #endif
    242 
    243250
    244251        ret = hc_init(&instance->hc, (void*)reg_base, reg_size, interrupts);
    245252        CHECK_RET_DEST_FREE_RETURN(ret,
    246             "Failed(%d) to init uhci_hcd: %s.\n", ret, str_error(ret));
     253            "Failed to init uhci_hcd: %s.\n", str_error(ret));
     254
     255        device->driver_data = instance;
    247256
    248257#define CHECK_RET_FINI_RETURN(ret, message...) \
     
    253262} else (void)0
    254263
    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 
    262264        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 
    267         ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME);
     265        CHECK_RET_FINI_RETURN(ret, "Failed to bind UHCI device function: %s.\n",
     266            str_error(ret));
     267
     268        ret = ddf_fun_add_to_category(instance->hc_fun, USB_HC_CATEGORY);
    268269        CHECK_RET_FINI_RETURN(ret,
    269270            "Failed to add UHCI to HC class: %s.\n", str_error(ret));
     
    272273            (uintptr_t)instance->hc.registers + 0x10, 4);
    273274        CHECK_RET_FINI_RETURN(ret,
    274             "Failed(%d) to setup UHCI root hub: %s.\n", ret, str_error(ret));
     275            "Failed to setup UHCI root hub: %s.\n", str_error(ret));
    275276
    276277        ret = ddf_fun_bind(instance->rh_fun);
    277278        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;
     279            "Failed to register UHCI root hub: %s.\n", str_error(ret));
     280
    281281        return EOK;
    282282#undef CHECK_RET_FINI_RETURN
Note: See TracChangeset for help on using the changeset viewer.