Changeset 52eead3e in mainline for uspace/drv/bus/usb/ohci/ohci.c


Ignore:
Timestamp:
2011-09-02T21:25:38Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
563d9d0a
Parents:
0f1586d0
Message:

ohci: cleanup device initialization

File:
1 edited

Legend:

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

    r0f1586d0 r52eead3e  
    4444#include "pci.h"
    4545#include "hc.h"
    46 #include "root_hub.h"
    4746
    4847typedef struct ohci {
     
    5150
    5251        hc_t hc;
    53         rh_t rh;
    5452} ohci_t;
    5553
     
    150148int device_setup_ohci(ddf_dev_t *device)
    151149{
     150        assert(device);
     151
    152152        ohci_t *instance = malloc(sizeof(ohci_t));
    153153        if (instance == NULL) {
     
    155155                return ENOMEM;
    156156        }
     157        instance->rh_fun = NULL;
     158        instance->hc_fun = NULL;
    157159
    158160#define CHECK_RET_DEST_FREE_RETURN(ret, message...) \
    159161if (ret != EOK) { \
    160162        if (instance->hc_fun) { \
    161                 instance->hc_fun->ops = NULL; \
    162                 instance->hc_fun->driver_data = NULL; \
    163163                ddf_fun_destroy(instance->hc_fun); \
    164164        } \
    165165        if (instance->rh_fun) { \
    166                 instance->rh_fun->ops = NULL; \
    167                 instance->rh_fun->driver_data = NULL; \
    168166                ddf_fun_destroy(instance->rh_fun); \
    169167        } \
    170168        free(instance); \
    171         device->driver_data = NULL; \
    172169        usb_log_error(message); \
    173170        return ret; \
    174171} else (void)0
    175172
    176         instance->rh_fun = NULL;
    177173        instance->hc_fun = ddf_fun_create(device, fun_exposed, "ohci_hc");
    178174        int ret = instance->hc_fun ? EOK : ENOMEM;
     
    194190        ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
    195191        CHECK_RET_DEST_FREE_RETURN(ret,
    196             "Failed to get memory addresses for %" PRIun ": %s.\n",
     192            "Failed to get register memory addresses for %" PRIun ": %s.\n",
    197193            device->handle, str_error(ret));
    198194        usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",
     
    201197        const size_t cmd_count = hc_irq_cmd_count();
    202198        irq_cmd_t irq_cmds[cmd_count];
     199        irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds };
     200
    203201        ret =
    204202            hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size);
     
    206204            "Failed to generate IRQ commands: %s.\n", str_error(ret));
    207205
    208         irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds };
    209206
    210207        /* Register handler to avoid interrupt lockup */
     
    251248        return EOK;
    252249
    253 #undef CHECK_RET_DEST_FUN_RETURN
    254250#undef CHECK_RET_FINI_RETURN
    255251}
Note: See TracChangeset for help on using the changeset viewer.