Ignore:
File:
1 edited

Legend:

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

    r366e9b6 r58563585  
    4545
    4646#include "hc.h"
    47 #include "ohci_bus.h"
    4847
    4948#define NAME "ohci"
    50 static int ohci_driver_init(hcd_t *, const hw_res_list_parsed_t *);
    51 static int ohci_driver_start(hcd_t *, bool);
    52 static int ohci_driver_claim(hcd_t *, ddf_dev_t *);
     49static int ohci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
    5350static void ohci_driver_fini(hcd_t *);
    5451
    5552static const ddf_hc_driver_t ohci_hc_driver = {
     53        .hc_speed = USB_SPEED_FULL,
    5654        .irq_code_gen = ohci_hc_gen_irq_code,
    5755        .init = ohci_driver_init,
    58         .claim = ohci_driver_claim,
    59         .start = ohci_driver_start,
    60         .setup_root_hub = hcd_setup_virtual_root_hub,
    6156        .fini = ohci_driver_fini,
    6257        .name = "OHCI",
    6358        .ops = {
    6459                .schedule       = ohci_hc_schedule,
     60                .ep_add_hook    = ohci_endpoint_init,
     61                .ep_remove_hook = ohci_endpoint_fini,
    6562                .irq_hook       = ohci_hc_interrupt,
    6663                .status_hook    = ohci_hc_status,
     
    6966
    7067
    71 static int ohci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res)
     68static int ohci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
    7269{
    73         int err;
    74 
    7570        assert(hcd);
    7671        assert(hcd_get_driver_data(hcd) == NULL);
     
    8075                return ENOMEM;
    8176
    82         if ((err = hc_init(instance, res)) != EOK)
    83                 goto err;
    84 
    85         if ((err = ohci_bus_init(&instance->bus, instance)))
    86                 goto err;
    87 
    88         hcd_set_implementation(hcd, instance, &ohci_hc_driver.ops, &instance->bus.base.base);
    89 
    90         return EOK;
    91 
    92 err:
    93         free(instance);
    94         return err;
    95 }
    96 
    97 static int ohci_driver_claim(hcd_t *hcd, ddf_dev_t *dev)
    98 {
    99         hc_t *hc = hcd_get_driver_data(hcd);
    100         assert(hc);
    101 
    102         hc_gain_control(hc);
    103 
    104         return EOK;
    105 }
    106 
    107 static int ohci_driver_start(hcd_t *hcd, bool interrupts)
    108 {
    109         hc_t *hc = hcd_get_driver_data(hcd);
    110         assert(hc);
    111 
    112         hc->hw_interrupts = interrupts;
    113         hc_start(hc);
    114         return EOK;
     77        const int ret = hc_init(instance, res, irq);
     78        if (ret == EOK) {
     79                hcd_set_implementation(hcd, instance, &ohci_hc_driver.ops);
     80        } else {
     81                free(instance);
     82        }
     83        return ret;
    11584}
    11685
     
    12291                hc_fini(hc);
    12392
    124         hcd_set_implementation(hcd, NULL, NULL, NULL);
     93        hcd_set_implementation(hcd, NULL, NULL);
    12594        free(hc);
    12695}
Note: See TracChangeset for help on using the changeset viewer.