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

    r2dbfe44 rb5f813c  
    4848#define NAME "uhci"
    4949
     50static int uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
     51static void uhci_driver_fini(hcd_t *);
     52static int disable_legacy(ddf_dev_t *);
     53
     54static const ddf_hc_driver_t uhci_hc_driver = {
     55        .claim = disable_legacy,
     56        .hc_speed = USB_SPEED_FULL,
     57        .irq_code_gen = uhci_hc_gen_irq_code,
     58        .init = uhci_driver_init,
     59        .fini = uhci_driver_fini,
     60        .name = "UHCI",
     61        .ops = {
     62                .schedule    = uhci_hc_schedule,
     63                .irq_hook    = uhci_hc_interrupt,
     64                .status_hook = uhci_hc_status,
     65        },
     66};
     67
    5068static int uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
    5169{
    5270        assert(hcd);
    53         assert(hcd->driver.data == NULL);
     71        assert(hcd_get_driver_data(hcd) == NULL);
    5472
    5573        hc_t *instance = malloc(sizeof(hc_t));
     
    5977        const int ret = hc_init(instance, res, irq);
    6078        if (ret == EOK)
    61                 hcd_set_implementation(hcd, instance, uhci_hc_schedule, NULL,
    62                     NULL, uhci_hc_interrupt, uhci_hc_status);
     79                hcd_set_implementation(hcd, instance, &uhci_hc_driver.ops);
    6380        return ret;
    6481}
     
    6784{
    6885        assert(hcd);
    69         if (hcd->driver.data)
    70                 hc_fini(hcd->driver.data);
     86        hc_t *hc = hcd_get_driver_data(hcd);
     87        if (hc)
     88                hc_fini(hc);
    7189
    72         free(hcd->driver.data);
    73         hcd_set_implementation(hcd, NULL, NULL, NULL, NULL, NULL, NULL);
     90        hcd_set_implementation(hcd, NULL, NULL);
     91        free(hc);
    7492}
    75 
    76 static int uhci_dev_add(ddf_dev_t *device);
    77 
    78 static const driver_ops_t uhci_driver_ops = {
    79         .dev_add = uhci_dev_add,
    80 };
    81 
    82 static const driver_t uhci_driver = {
    83         .name = NAME,
    84         .driver_ops = &uhci_driver_ops
    85 };
    8693
    8794/** Call the PCI driver with a request to clear legacy support register
     
    106113        return rc;
    107114}
    108 static const ddf_hc_driver_t uhci_hc_driver = {
    109         .claim = disable_legacy,
    110         .hc_speed = USB_SPEED_FULL,
    111         .irq_code_gen = uhci_hc_gen_irq_code,
    112         .init = uhci_driver_init,
    113         .fini = uhci_driver_fini,
    114         .name = "UHCI"
    115 };
    116 
    117115
    118116/** Initialize a new ddf driver instance for uhci hc and hub.
     
    121119 * @return Error code.
    122120 */
    123 int uhci_dev_add(ddf_dev_t *device)
     121static int uhci_dev_add(ddf_dev_t *device)
    124122{
    125123        usb_log_debug2("uhci_dev_add() called\n");
     
    127125        return hcd_ddf_add_hc(device, &uhci_hc_driver);
    128126}
     127
     128static const driver_ops_t uhci_driver_ops = {
     129        .dev_add = uhci_dev_add,
     130};
     131
     132static const driver_t uhci_driver = {
     133        .name = NAME,
     134        .driver_ops = &uhci_driver_ops
     135};
     136
    129137
    130138/** Initialize global driver structures (NONE).
Note: See TracChangeset for help on using the changeset viewer.