Ignore:
File:
1 edited

Legend:

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

    r44c1a48 r27ed734c  
    4242
    4343#include "ohci.h"
    44 #include "res.h"
     44#include "pci.h"
    4545#include "hc.h"
    4646
     
    140140int device_setup_ohci(ddf_dev_t *device)
    141141{
    142         if (device == NULL)
    143                 return EBADMEM;
    144 
    145         ohci_t *instance = ddf_dev_data_alloc(device,sizeof(ohci_t));
     142        assert(device);
     143
     144        ohci_t *instance = malloc(sizeof(ohci_t));
    146145        if (instance == NULL) {
    147146                usb_log_error("Failed to allocate OHCI driver.\n");
    148147                return ENOMEM;
    149148        }
     149        instance->rh_fun = NULL;
     150        instance->hc_fun = NULL;
    150151
    151152#define CHECK_RET_DEST_FREE_RETURN(ret, message...) \
    152153if (ret != EOK) { \
    153154        if (instance->hc_fun) { \
    154                 instance->hc_fun->driver_data = NULL; \
    155155                ddf_fun_destroy(instance->hc_fun); \
    156156        } \
    157157        if (instance->rh_fun) { \
    158                 instance->rh_fun->driver_data = NULL; \
    159158                ddf_fun_destroy(instance->rh_fun); \
    160159        } \
     160        free(instance); \
    161161        usb_log_error(message); \
    162162        return ret; \
     
    180180        int irq = 0;
    181181
    182         ret = get_my_registers(device, &reg_base, &reg_size, &irq);
     182        ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
    183183        CHECK_RET_DEST_FREE_RETURN(ret,
    184184            "Failed to get register memory addresses for %" PRIun ": %s.\n",
     
    187187            (void *) reg_base, reg_size, irq);
    188188
    189         const size_t ranges_count = hc_irq_pio_range_count();
    190         const size_t cmds_count = hc_irq_cmd_count();
    191         irq_pio_range_t irq_ranges[ranges_count];
    192         irq_cmd_t irq_cmds[cmds_count];
    193         irq_code_t irq_code = {
    194                 .rangecount = ranges_count,
    195                 .ranges = irq_ranges,
    196                 .cmdcount = cmds_count,
    197                 .cmds = irq_cmds
    198         };
    199 
    200         ret = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds,
    201             sizeof(irq_cmds), reg_base, reg_size);
    202         CHECK_RET_DEST_FREE_RETURN(ret,
    203             "Failed to generate IRQ code: %s.\n", str_error(ret));
     189        const size_t cmd_count = hc_irq_cmd_count();
     190        irq_cmd_t irq_cmds[cmd_count];
     191        irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds };
     192
     193        ret =
     194            hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size);
     195        CHECK_RET_DEST_FREE_RETURN(ret,
     196            "Failed to generate IRQ commands: %s.\n", str_error(ret));
    204197
    205198
     
    211204        /* Try to enable interrupts */
    212205        bool interrupts = false;
    213         ret = enable_interrupts(device);
     206        ret = pci_enable_interrupts(device);
    214207        if (ret != EOK) {
    215208                usb_log_warning("Failed to enable interrupts: %s."
     
    226219            "Failed to init ohci_hcd: %s.\n", str_error(ret));
    227220
     221        device->driver_data = instance;
     222
    228223#define CHECK_RET_FINI_RETURN(ret, message...) \
    229224if (ret != EOK) { \
Note: See TracChangeset for help on using the changeset viewer.