Changeset b5f813c in mainline for uspace/drv/bus/usb/ehci/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/ehci/main.c

    r2dbfe44 rb5f813c  
    5050#define NAME "ehci"
    5151
     52static int ehci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
     53static void ehci_driver_fini(hcd_t *);
     54
     55static const ddf_hc_driver_t ehci_hc_driver = {
     56        .claim = disable_legacy,
     57        .hc_speed = USB_SPEED_HIGH,
     58        .irq_code_gen = ehci_hc_gen_irq_code,
     59        .init = ehci_driver_init,
     60        .fini = ehci_driver_fini,
     61        .name = "EHCI-PCI",
     62        .ops = {
     63                .schedule       = ehci_hc_schedule,
     64                .ep_add_hook    = ehci_endpoint_init,
     65                .ep_remove_hook = ehci_endpoint_fini,
     66                .irq_hook       = ehci_hc_interrupt,
     67                .status_hook    = ehci_hc_status,
     68        }
     69};
     70
     71
    5272static int ehci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
    5373{
    5474        assert(hcd);
    55         assert(hcd->driver.data == NULL);
     75        assert(hcd_get_driver_data(hcd) == NULL);
    5676
    5777        hc_t *instance = malloc(sizeof(hc_t));
     
    6181        const int ret = hc_init(instance, res, irq);
    6282        if (ret == EOK)
    63                 hcd_set_implementation(hcd, instance, ehci_hc_schedule,
    64                     ehci_endpoint_init, ehci_endpoint_fini, ehci_hc_interrupt,
    65                     ehci_hc_status);
     83                hcd_set_implementation(hcd, instance, &ehci_hc_driver.ops);
    6684        return ret;
    6785}
     
    7088{
    7189        assert(hcd);
    72         if (hcd->driver.data)
    73                 hc_fini(hcd->driver.data);
     90        hc_t *hc = hcd_get_driver_data(hcd);
     91        if (hc)
     92                hc_fini(hc);
    7493
    75         free(hcd->driver.data);
    76         hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL, NULL);
     94        free(hc);
     95        hcd_set_implementation(hcd, NULL, NULL);
    7796}
    78 
    79 static int ehci_dev_add(ddf_dev_t *device);
    80 
    81 static const driver_ops_t ehci_driver_ops = {
    82         .dev_add = ehci_dev_add,
    83 };
    84 
    85 static const driver_t ehci_driver = {
    86         .name = NAME,
    87         .driver_ops = &ehci_driver_ops
    88 };
    89 
    90 
    91 static const ddf_hc_driver_t ehci_hc_driver = {
    92         .claim = disable_legacy,
    93         .hc_speed = USB_SPEED_HIGH,
    94         .irq_code_gen = ehci_hc_gen_irq_code,
    95         .init = ehci_driver_init,
    96         .fini = ehci_driver_fini,
    97         .name = "EHCI-PCI"
    98 };
    9997
    10098/** Initializes a new ddf driver instance of EHCI hcd.
     
    111109
    112110}
     111
     112
     113static const driver_ops_t ehci_driver_ops = {
     114        .dev_add = ehci_dev_add,
     115};
     116
     117static const driver_t ehci_driver = {
     118        .name = NAME,
     119        .driver_ops = &ehci_driver_ops
     120};
     121
    113122
    114123/** Initializes global driver structures (NONE).
Note: See TracChangeset for help on using the changeset viewer.