xhci: move bus_state structure under the xhci_hub structure.
Subsystems (2)
PATCH 2/8 xhci: move bus_state structure under the xhci_hub structure.
Move the bus_state structure under struct usb_hub.
We need a bus_state strucure for each roothub to keep track of suspend related info for each port.
Instead of keeping an array of two bus_state structures right under struct xhci, it makes more sense move them to the xhci_hub structure.
No functional changes.
Signed-off-by Mathias Nyman <[email protected]>
--- drivers/usb/host/xhci-hub.c | 15 ++++++--------- drivers/usb/host/xhci-mem.c | 10 +++++----- drivers/usb/host/xhci-ring.c | 2 +- drivers/usb/host/xhci.c | 19 ++++++++++--------- drivers/usb/host/xhci.h | 4 ++-- 5 files changed, 24 insertions(+), 26 deletions(-)
drivers/usb/host/xhci-hub.c +6 -9
@@ -1031,7 +1031,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, rhub =xhci_get_rhub (hcd); ports = rhub->ports; max_ports = rhub->num_ports; - bus_state = &xhci->bus_state[hcd_index (hcd)]; + bus_state = &rhub->bus_state;spin_lock_irqsave (&xhci->lock, flags);switch (typeReq) {
@@ -1421,7 +1421,7 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf) rhub =xhci_get_rhub (hcd); ports = rhub->ports; max_ports = rhub->num_ports; - bus_state = &xhci->bus_state[hcd_index (hcd)]; + bus_state = &rhub->bus_state;/* Initial status is no changes */ retval = (max_ports +8 ) /8 ;
@@ -1480,7 +1480,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd) rhub =xhci_get_rhub (hcd); ports = rhub->ports; max_ports = rhub->num_ports; - bus_state = &xhci->bus_state[hcd_index (hcd)]; + bus_state = &rhub->bus_state; wake_enabled = hcd->self.root_hub->do_remote_wakeup;spin_lock_irqsave (&xhci->lock, flags);
@@ -1622,7 +1622,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) rhub =xhci_get_rhub (hcd); ports = rhub->ports; max_ports = rhub->num_ports; - bus_state = &xhci->bus_state[hcd_index (hcd)]; + bus_state = &rhub->bus_state;if (time_before (jiffies, bus_state->next_statechange))msleep (5 );
@@ -1723,13 +1723,10 @@ int xhci_bus_resume(struct usb_hcd *hcd)unsigned long xhci_get_resuming_ports (struct usb_hcd *hcd) { -struct xhci_hcd *xhci =hcd_to_xhci (hcd); -struct xhci_bus_state *bus_state; - - bus_state = &xhci->bus_state[hcd_index (hcd)]; +struct xhci_hub *rhub =xhci_get_rhub (hcd);/* USB3 port wakeups are reported via usb_wakeup_notification() */ -return bus_state->resuming_ports;/* USB2 ports only */ +return rhub->bus_state.resuming_ports;/* USB2 ports only */ }#endif /* CONFIG_PM */
drivers/usb/host/xhci-mem.c +5 -5
@@ -1922,8 +1922,8 @@ void xhci_mem_cleanup(struct xhci_hcd *xhci) xhci->page_size =0 ; xhci->page_shift =0 ; - xhci->bus_state[0 ].bus_suspended =0 ; - xhci->bus_state[1 ].bus_suspended =0 ; + xhci->usb2_rhub.bus_state.bus_suspended =0 ; + xhci->usb3_rhub.bus_state.bus_suspended =0 ; } static int xhci_test_trb_in_td(struct xhci_hcd *xhci,
@@ -2524,10 +2524,10 @@ int xhci_mem_init(struct xhci_hcd *xhci, gfp_t flags)for (i =0 ; i <MAX_HC_SLOTS ; i++) xhci->devs[i] =NULL ;for (i =0 ; i <USB_MAXCHILDREN ; i++) { - xhci->bus_state[0 ].resume_done[i] =0 ; - xhci->bus_state[1 ].resume_done[i] =0 ; + xhci->usb2_rhub.bus_state.resume_done[i] =0 ; + xhci->usb3_rhub.bus_state.resume_done[i] =0 ;/* Only the USB 2.0 completions will ever be used. */ -init_completion (&xhci->bus_state[1 ].rexit_done[i]); +init_completion (&xhci->usb2_rhub.bus_state.rexit_done[i]); }if (scratchpad_alloc (xhci, flags))
drivers/usb/host/xhci-ring.c +1 -1
@@ -1593,7 +1593,7 @@ static void handle_port_status(struct xhci_hcd *xhci, } hcd = port->rhub->hcd; - bus_state = &xhci->bus_state[hcd_index (hcd)]; + bus_state = &port->rhub->bus_state; hcd_portnum = port->hcd_portnum; portsc =readl (port->addr);
drivers/usb/host/xhci.c +10 -9
@@ -169,7 +169,7 @@ int xhci_reset(struct xhci_hcd *xhci) {u32 command;u32 state; -int ret, i; +int ret; state =readl (&xhci->op_regs->status);
@@ -215,11 +215,12 @@ int xhci_reset(struct xhci_hcd *xhci) ret =xhci_handshake (&xhci->op_regs->status,STS_CNR ,0 ,10 *1000 *1000 ); -for (i =0 ; i <2 ; i++) { - xhci->bus_state[i].port_c_suspend =0 ; - xhci->bus_state[i].suspended_ports =0 ; - xhci->bus_state[i].resuming_ports =0 ; - } + xhci->usb2_rhub.bus_state.port_c_suspend =0 ; + xhci->usb2_rhub.bus_state.suspended_ports =0 ; + xhci->usb2_rhub.bus_state.resuming_ports =0 ; + xhci->usb3_rhub.bus_state.port_c_suspend =0 ; + xhci->usb3_rhub.bus_state.suspended_ports =0 ; + xhci->usb3_rhub.bus_state.resuming_ports =0 ;return ret; }
@@ -1069,9 +1070,9 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)/* Wait a bit if either of the roothubs need to settle from the * transition into bus suspend. */ -if (time_before (jiffies, xhci->bus_state[0 ].next_statechange) || -time_before (jiffies, - xhci->bus_state[1 ].next_statechange)) + +if (time_before (jiffies, xhci->usb2_rhub.bus_state.next_statechange) || +time_before (jiffies, xhci->usb3_rhub.bus_state.next_statechange))msleep (100 );set_bit (HCD_FLAG_HW_ACCESSIBLE , &hcd->flags);
drivers/usb/host/xhci.h +2 -2
@@ -1700,6 +1700,8 @@ struct xhci_hub {struct xhci_port **ports;unsigned int num_ports;struct usb_hcd *hcd; +/* keep track of bus suspend info */ +struct xhci_bus_state bus_state;/* supported prococol extended capabiliy values */ u8 maj_rev;u8 min_rev;
@@ -1853,8 +1855,6 @@ struct xhci_hcd {unsigned int num_active_eps;unsigned int limit_active_eps; -/* There are two roothubs to keep track of bus suspend info for */ -struct xhci_bus_state bus_state[2 ];struct xhci_port *hw_ports;struct xhci_hub usb2_rhub;struct xhci_hub usb3_rhub;