Changeset 0f79283b in mainline for uspace/drv


Ignore:
Timestamp:
2018-01-18T12:39:27Z (8 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2bff2cc2
Parents:
babcc423
Message:

usb: remove speed storing (and fix that misuse in xhci rh)

Location:
uspace/drv/bus/usb
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/port.c

    rbabcc423 r0f79283b  
    134134        port_log(debug, port, "Port reset, enumerating device.");
    135135
    136         if ((err = usbhc_device_enumerate(exch, port->port_number, port->base.speed))) {
     136        if ((err = usbhc_device_enumerate(exch, port->port_number, port->speed))) {
    137137                port_log(error, port, "Failed to enumerate device: %s", str_error(err));
    138138                /* Disable the port */
     
    200200        const bool enabled = !!(status & USB_HUB_PORT_STATUS_ENABLED);
    201201
    202         if (enabled)
    203                 usb_port_enabled(&port->base, usb_port_speed(status));
    204         else
     202        if (enabled) {
     203                // The connecting fibril do not touch speed until the port is enabled,
     204                // so we do not have to lock
     205                port->speed = usb_port_speed(status);
     206                usb_port_enabled(&port->base);
     207        } else
    205208                usb_port_disabled(&port->base, &remove_device);
    206209}
  • uspace/drv/bus/usb/usbhub/port.h

    rbabcc423 r0f79283b  
    5252        /** Port number as reported in descriptors. */
    5353        unsigned int port_number;
     54        /** Speed at the time of enabling the port */
     55        usb_speed_t speed;
    5456} usb_hub_port_t;
    5557
  • uspace/drv/bus/usb/xhci/rh.c

    rbabcc423 r0f79283b  
    136136        }
    137137
    138         device_t *dev = hcd_ddf_fun_create(&port->rh->hc->base, port->base.speed);
     138        /*
     139         * We cannot know in advance, whether the speed in the status register
     140         * is valid - it depends on the protocol. So we read it later, but then
     141         * we have to check if the port is still enabled.
     142         */
     143        uint32_t status = XHCI_REG_RD_FIELD(&port->regs->portsc, 32);
     144
     145        bool enabled = !!(status & XHCI_REG_MASK(XHCI_PORT_PED));
     146        if (!enabled)
     147                return ENOENT;
     148
     149        unsigned psiv = (status & XHCI_REG_MASK(XHCI_PORT_PS)) >> XHCI_REG_SHIFT(XHCI_PORT_PS);
     150        const usb_speed_t speed = port->rh->hc->speeds[psiv].usb_speed;
     151
     152        device_t *dev = hcd_ddf_fun_create(&port->rh->hc->base, speed);
    139153        if (!dev) {
    140154                usb_log_error("Failed to create USB device function.");
     
    223237
    224238                        if (enabled) {
    225                                 unsigned psiv = (status & XHCI_REG_MASK(XHCI_PORT_PS)) >> XHCI_REG_SHIFT(XHCI_PORT_PS);
    226                                 const usb_speed_t speed = rh->hc->speeds[psiv].usb_speed;
    227                                 usb_port_enabled(&port->base, speed);
     239                                usb_port_enabled(&port->base);
    228240                        } else {
    229241                                usb_port_disabled(&port->base, &rh_remove_device);
Note: See TracChangeset for help on using the changeset viewer.