[11/16] xhci: xhci-hub: use port structure members instead of xhci_get_ports()

Message ID 20180703072029.14289-12-kai.heng.feng@canonical.com
State New
Headers show
Series
  • Fix "xHCI host controller not responding, assume dead"
Related show

Commit Message

Kai-Heng Feng July 3, 2018, 7:20 a.m.
From: Mathias Nyman <mathias.nyman@linux.intel.com>

BugLink: https://bugs.launchpad.net/bugs/1763594

xhci_get_ports() is one of the last functions using port_arrays in
xhci-hub.c. We get the same data directly from hub and port structures
instead, so convert and remove both xhci_get_ports() and port_arrays from
all function that no longer need it.

Signed-off-by: Mathias Nyman <mathias.nyman@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 925f349d4dca1357813efdc37ec08134d79b3288)
Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
 drivers/usb/host/xhci-hub.c | 28 ++++------------------------
 1 file changed, 4 insertions(+), 24 deletions(-)

Patch

diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c
index 42b7de72b2d5..fd9865987f09 100644
--- a/drivers/usb/host/xhci-hub.c
+++ b/drivers/usb/host/xhci-hub.c
@@ -542,22 +542,6 @@  static void xhci_clear_port_change_bit(struct xhci_hcd *xhci, u16 wValue,
 			port_change_bit, wIndex, port_status);
 }
 
-static int xhci_get_ports(struct usb_hcd *hcd, __le32 __iomem ***port_array)
-{
-	int max_ports;
-	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
-
-	if (hcd->speed >= HCD_USB3) {
-		max_ports = xhci->num_usb3_ports;
-		*port_array = xhci->usb3_ports;
-	} else {
-		max_ports = xhci->num_usb2_ports;
-		*port_array = xhci->usb2_ports;
-	}
-
-	return max_ports;
-}
-
 struct xhci_hub *xhci_get_rhub(struct usb_hcd *hcd)
 {
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
@@ -1033,7 +1017,6 @@  int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 	unsigned long flags;
 	u32 temp, status;
 	int retval = 0;
-	__le32 __iomem **port_array;
 	int slot_id;
 	struct xhci_bus_state *bus_state;
 	u16 link_state = 0;
@@ -1045,7 +1028,7 @@  int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
 
 	rhub = xhci_get_rhub(hcd);
 	ports = rhub->ports;
-	max_ports = xhci_get_ports(hcd, &port_array);
+	max_ports = rhub->num_ports;
 	bus_state = &xhci->bus_state[hcd_index(hcd)];
 
 	spin_lock_irqsave(&xhci->lock, flags);
@@ -1425,7 +1408,6 @@  int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
 	int i, retval;
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	int max_ports;
-	__le32 __iomem **port_array;
 	struct xhci_bus_state *bus_state;
 	bool reset_change = false;
 	struct xhci_hub *rhub;
@@ -1433,7 +1415,7 @@  int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
 
 	rhub = xhci_get_rhub(hcd);
 	ports = rhub->ports;
-	max_ports = xhci_get_ports(hcd, &port_array);
+	max_ports = rhub->num_ports;
 	bus_state = &xhci->bus_state[hcd_index(hcd)];
 
 	/* Initial status is no changes */
@@ -1481,7 +1463,6 @@  int xhci_bus_suspend(struct usb_hcd *hcd)
 {
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	int max_ports, port_index;
-	__le32 __iomem **port_array;
 	struct xhci_bus_state *bus_state;
 	unsigned long flags;
 	struct xhci_hub *rhub;
@@ -1489,7 +1470,7 @@  int xhci_bus_suspend(struct usb_hcd *hcd)
 
 	rhub = xhci_get_rhub(hcd);
 	ports = rhub->ports;
-	max_ports = xhci_get_ports(hcd, &port_array);
+	max_ports = rhub->num_ports;
 	bus_state = &xhci->bus_state[hcd_index(hcd)];
 
 	spin_lock_irqsave(&xhci->lock, flags);
@@ -1583,7 +1564,6 @@  int xhci_bus_resume(struct usb_hcd *hcd)
 {
 	struct xhci_hcd	*xhci = hcd_to_xhci(hcd);
 	struct xhci_bus_state *bus_state;
-	__le32 __iomem **port_array;
 	unsigned long flags;
 	int max_ports, port_index;
 	int slot_id;
@@ -1595,7 +1575,7 @@  int xhci_bus_resume(struct usb_hcd *hcd)
 
 	rhub = xhci_get_rhub(hcd);
 	ports = rhub->ports;
-	max_ports = xhci_get_ports(hcd, &port_array);
+	max_ports = rhub->num_ports;
 	bus_state = &xhci->bus_state[hcd_index(hcd)];
 
 	if (time_before(jiffies, bus_state->next_statechange))