Changeset 766043c in mainline for uspace/drv/bus/usb/xhci/rh.c


Ignore:
Timestamp:
2017-10-21T23:18:09Z (7 years ago)
Author:
Petr Manek <petr.manek@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2b61945
Parents:
5fd9c30
Message:

Keeping track of root hub devices by port id.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/xhci/rh.c

    r5fd9c30 r766043c  
    6868        rh->hc = hc;
    6969        rh->max_ports = XHCI_REG_RD(hc->cap_regs, XHCI_CAP_MAX_PORTS);
     70        rh->devices = (xhci_device_t **) malloc(rh->max_ports * sizeof(xhci_device_t *));
    7071        hc->rh.hc_device = device;
     72
     73        memset(rh->devices, 0, rh->max_ports * sizeof(xhci_device_t *));
    7174
    7275        return device_init(&hc->rh.device);
     
    175178        xhci_dev->hc = hc;
    176179
    177         // TODO: Save anything else?
     180        if (!rh->devices[dev->port - 1]) {
     181                /* Only save the device if it's the first one connected to this port. */
     182                rh->devices[dev->port - 1] = xhci_dev;
     183        }
    178184
    179185        return EOK;
     
    280286static int handle_disconnected_device(xhci_rh_t *rh, uint8_t port_id)
    281287{
    282         // TODO: Find XHCI device by the port.
     288        /* Find XHCI device by the port. */
     289        xhci_device_t *dev = rh->devices[port_id - 1];
     290        if (!dev) {
     291                /* Must be extraneous call */
     292                return EOK;
     293        }
     294
     295        usb_log_info("Device at port %u has been disconnected.", port_id);
     296
    283297        // TODO: Destroy DDF function using _gone.
    284298        // TODO: Remove device endpoints on the bus.
     
    437451        /* TODO: Implement me! */
    438452        usb_log_debug2("Called xhci_rh_fini().");
     453
     454        free(rh->devices);
     455
    439456        return EOK;
    440457}
Note: See TracChangeset for help on using the changeset viewer.