OSDN Git Service

xhci: refactor U0 link state handling in get_port_status
authorMathias Nyman <mathias.nyman@linux.intel.com>
Fri, 7 Dec 2018 14:19:35 +0000 (16:19 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 7 Dec 2018 14:40:41 +0000 (15:40 +0100)
Move U0 link state handing to USB3 and USB2 specific functions

Note that
bus_state->resuming_ports:
bus_state->resume_done[]:
are only used for USB2, and don't need to cleared for USB3 ports

No functional changes

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/host/xhci-hub.c

index c0de2d0..d86d1d5 100644 (file)
@@ -814,10 +814,12 @@ static u32 xhci_get_ext_port_status(u32 raw_port_status, u32 port_li)
 static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
                                      u32 portsc)
 {
+       struct xhci_bus_state *bus_state;
        struct xhci_hcd *xhci;
        u32 link_state;
        u32 portnum;
 
+       bus_state = &port->rhub->bus_state;
        xhci = hcd_to_xhci(port->rhub->hcd);
        link_state = portsc & PORT_PLS_MASK;
        portnum = port->hcd_portnum;
@@ -839,8 +841,12 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
                *status |= USB_PORT_STAT_C_CONFIG_ERROR << 16;
 
        /* USB3 specific wPortStatus bits */
-       if (portsc & PORT_POWER)
+       if (portsc & PORT_POWER) {
                *status |= USB_SS_PORT_STAT_POWER;
+               /* link state handling */
+               if (link_state == XDEV_U0)
+                       bus_state->suspended_ports &= ~(1 << portnum);
+       }
 
        xhci_hub_report_usb3_link_state(xhci, status, portsc);
        xhci_del_comp_mod_timer(xhci, portsc, portnum);
@@ -849,9 +855,13 @@ static void xhci_get_usb3_port_status(struct xhci_port *port, u32 *status,
 static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
                                      u32 portsc)
 {
+       struct xhci_bus_state *bus_state;
        u32 link_state;
+       u32 portnum;
 
+       bus_state = &port->rhub->bus_state;
        link_state = portsc & PORT_PLS_MASK;
+       portnum = port->hcd_portnum;
 
        /* USB2 wPortStatus bits */
        if (portsc & PORT_POWER) {
@@ -862,6 +872,14 @@ static void xhci_get_usb2_port_status(struct xhci_port *port, u32 *status,
                        *status |= USB_PORT_STAT_SUSPEND;
                if (link_state == XDEV_U2)
                        *status |= USB_PORT_STAT_L1;
+               if (link_state == XDEV_U0) {
+                       bus_state->resume_done[portnum] = 0;
+                       clear_bit(portnum, &bus_state->resuming_ports);
+                       if (bus_state->suspended_ports & (1 << portnum)) {
+                               bus_state->suspended_ports &= ~(1 << portnum);
+                               bus_state->port_c_suspend |= 1 << portnum;
+                       }
+               }
        }
 }
 
@@ -1011,18 +1029,6 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd,
                usb_hcd_end_port_resume(&hcd->self, wIndex);
        }
 
-
-       if ((raw_port_status & PORT_PLS_MASK) == XDEV_U0 &&
-           (raw_port_status & PORT_POWER)) {
-               if (bus_state->suspended_ports & (1 << wIndex)) {
-                       bus_state->suspended_ports &= ~(1 << wIndex);
-                       if (hcd->speed < HCD_USB3)
-                               bus_state->port_c_suspend |= 1 << wIndex;
-               }
-               bus_state->resume_done[wIndex] = 0;
-               clear_bit(wIndex, &bus_state->resuming_ports);
-       }
-
        if (bus_state->port_c_suspend & (1 << wIndex))
                status |= USB_PORT_STAT_C_SUSPEND << 16;