Ignore:
File:
1 edited

Legend:

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

    r58563585 r366e9b6  
    4545
    4646#include "hc.h"
     47#include "ohci_bus.h"
    4748
    4849#define NAME "ohci"
    49 static int ohci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
     50static int ohci_driver_init(hcd_t *, const hw_res_list_parsed_t *);
     51static int ohci_driver_start(hcd_t *, bool);
     52static int ohci_driver_claim(hcd_t *, ddf_dev_t *);
    5053static void ohci_driver_fini(hcd_t *);
    5154
    5255static const ddf_hc_driver_t ohci_hc_driver = {
    53         .hc_speed = USB_SPEED_FULL,
    5456        .irq_code_gen = ohci_hc_gen_irq_code,
    5557        .init = ohci_driver_init,
     58        .claim = ohci_driver_claim,
     59        .start = ohci_driver_start,
     60        .setup_root_hub = hcd_setup_virtual_root_hub,
    5661        .fini = ohci_driver_fini,
    5762        .name = "OHCI",
    5863        .ops = {
    5964                .schedule       = ohci_hc_schedule,
    60                 .ep_add_hook    = ohci_endpoint_init,
    61                 .ep_remove_hook = ohci_endpoint_fini,
    6265                .irq_hook       = ohci_hc_interrupt,
    6366                .status_hook    = ohci_hc_status,
     
    6669
    6770
    68 static int ohci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
     71static int ohci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res)
    6972{
     73        int err;
     74
    7075        assert(hcd);
    7176        assert(hcd_get_driver_data(hcd) == NULL);
     
    7580                return ENOMEM;
    7681
    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;
     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
     92err:
     93        free(instance);
     94        return err;
     95}
     96
     97static 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
     107static 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;
    84115}
    85116
     
    91122                hc_fini(hc);
    92123
    93         hcd_set_implementation(hcd, NULL, NULL);
     124        hcd_set_implementation(hcd, NULL, NULL, NULL);
    94125        free(hc);
    95126}
Note: See TracChangeset for help on using the changeset viewer.