Changeset b5f813c in mainline for uspace/drv/bus/usb/ohci/main.c


Ignore:
Timestamp:
2015-07-04T03:28:02Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
55346870
Parents:
2dbfe44
Message:

libusbhost,ehci,ohci,uhci,vhc: Pass ops structure instead of function pointers to intialization

File:
1 edited

Legend:

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

    r2dbfe44 rb5f813c  
    4646
    4747#define NAME "ohci"
     48static int ohci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
     49static void ohci_driver_fini(hcd_t *);
     50
     51static const ddf_hc_driver_t ohci_hc_driver = {
     52        .hc_speed = USB_SPEED_FULL,
     53        .irq_code_gen = ohci_hc_gen_irq_code,
     54        .init = ohci_driver_init,
     55        .fini = ohci_driver_fini,
     56        .name = "OHCI",
     57        .ops = {
     58                .schedule       = ohci_hc_schedule,
     59                .ep_add_hook    = ohci_endpoint_init,
     60                .ep_remove_hook = ohci_endpoint_fini,
     61                .irq_hook       = ohci_hc_interrupt,
     62                .status_hook    = ohci_hc_status,
     63        },
     64};
     65
    4866
    4967static int ohci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
    5068{
    5169        assert(hcd);
    52         assert(hcd->driver.data == NULL);
     70        assert(hcd_get_driver_data(hcd) == NULL);
    5371
    5472        hc_t *instance = malloc(sizeof(hc_t));
     
    5876        const int ret = hc_init(instance, res, irq);
    5977        if (ret == EOK)
    60                 hcd_set_implementation(hcd, instance, ohci_hc_schedule,
    61                     ohci_endpoint_init, ohci_endpoint_fini, ohci_hc_interrupt,
    62                     ohci_hc_status);
     78                hcd_set_implementation(hcd, instance, &ohci_hc_driver.ops);
    6379        return ret;
    6480}
     
    6783{
    6884        assert(hcd);
    69         if (hcd->driver.data)
    70                 hc_fini(hcd->driver.data);
     85        hc_t *hc = hcd_get_driver_data(hcd);
     86        if (hc)
     87                hc_fini(hc);
    7188
    72         free(hcd->driver.data);
    73         hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL, NULL);
     89        hcd_set_implementation(hcd, NULL, NULL);
     90        free(hc);
    7491}
    75 
    76 static const ddf_hc_driver_t ohci_hc_driver = {
    77         .hc_speed = USB_SPEED_FULL,
    78         .irq_code_gen = ohci_hc_gen_irq_code,
    79         .init = ohci_driver_init,
    80         .fini = ohci_driver_fini,
    81         .name = "OHCI"
    82 };
    8392
    8493/** Initializes a new ddf driver instance of OHCI hcd.
Note: See TracChangeset for help on using the changeset viewer.