Changeset 32fb6bce in mainline for uspace/drv/bus/usb/vhc/main.c


Ignore:
Timestamp:
2017-12-18T22:50:21Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7f70d1c
Parents:
1ea0bbf
git-author:
Ondřej Hlavatý <aearsis@…> (2017-12-18 22:04:50)
git-committer:
Ondřej Hlavatý <aearsis@…> (2017-12-18 22:50:21)
Message:

usbhost: refactoring

This commit moves interrupt, status and schedule to bus
operations. Then the purpose of hcd_t is better defined, and split into
hc_driver_t and hc_device_t. hc_driver_t is used to wrap driver
implementation by the library (similar to how usb_driver_t is used to
wrap usb device drivers). hc_device_t is used as a parent for hc_t
inside drivers, and is allocated inside the DDF device node.

To support these changes, some local identifiers were renamed, some
functions were moved and/or renamed and their arguments changed. The
most notable one being hcd_send_batch → bus_device_send_batch.

File:
1 edited

Legend:

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

    r1ea0bbf r32fb6bce  
    6969                return ret;
    7070        }
    71         vhc_init(vhc, dev_to_hcd(dev));
    7271        return EOK;
    7372}
    7473
    75 hcd_ops_t vhc_hc_ops = {
    76         .schedule = vhc_schedule,
    77 };
    78 
    7974static int vhc_dev_add(ddf_dev_t *dev)
    8075{
     76        /* Initialize generic structures */
     77        int ret = hcd_ddf_setup_hc(dev, sizeof(vhc_data_t));
     78        if (ret != EOK) {
     79                usb_log_error("Failed to init HCD structures: %s.\n",
     80                   str_error(ret));
     81                return ret;
     82        }
     83        vhc_data_t *vhc = ddf_dev_data_get(dev);
     84        vhc_init(vhc);
     85
     86        hc_device_setup(&vhc->base, (bus_t *) &vhc->bus);
     87
    8188        /* Initialize virtual structure */
    8289        ddf_fun_t *ctl_fun = NULL;
    83         int ret = vhc_control_node(dev, &ctl_fun);
     90        ret = vhc_control_node(dev, &ctl_fun);
    8491        if (ret != EOK) {
    8592                usb_log_error("Failed to setup control node.\n");
    8693                return ret;
    8794        }
    88         vhc_data_t *data = ddf_fun_data_get(ctl_fun);
    89 
    90         /* Initialize generic structures */
    91         ret = hcd_ddf_setup_hc(dev);
    92         if (ret != EOK) {
    93                 usb_log_error("Failed to init HCD structures: %s.\n",
    94                    str_error(ret));
    95                 ddf_fun_destroy(ctl_fun);
    96                 return ret;
    97         }
    98 
    99         hcd_set_implementation(dev_to_hcd(dev), data, &vhc_hc_ops, &data->bus.base);
    10095
    10196        /* Add virtual hub device */
    102         ret = vhc_virtdev_plug_hub(data, &data->hub, NULL, 0);
     97        ret = vhc_virtdev_plug_hub(vhc, &vhc->hub, NULL, 0);
    10398        if (ret != EOK) {
    10499                usb_log_error("Failed to plug root hub: %s.\n", str_error(ret));
     
    111106         * needs to be ready at this time.
    112107         */
    113         ret = hcd_setup_virtual_root_hub(dev_to_hcd(dev), dev);
     108        ret = hcd_setup_virtual_root_hub(&vhc->base);
    114109        if (ret != EOK) {
    115110                usb_log_error("Failed to init VHC root hub: %s\n",
Note: See TracChangeset for help on using the changeset viewer.