Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 248861
b: refs/heads/master
c: a088592
h: refs/heads/master
i:
  248859: 90cd509
v: v3
  • Loading branch information
huajun li authored and Sarah Sharp committed May 12, 2011
1 parent d3f43d3 commit 2f2ce3b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 40 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3610ea5397b80822e417aaa0e706fd803fb05680
refs/heads/master: a0885924326f79e157847010a9aaf49b058b30dc
66 changes: 27 additions & 39 deletions trunk/drivers/usb/host/xhci-hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,27 @@ 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;
}

int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
u16 wIndex, char *buf, u16 wLength)
{
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
int ports;
int max_ports;
unsigned long flags;
u32 temp, temp1, status;
int retval = 0;
Expand All @@ -389,13 +405,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
struct xhci_bus_state *bus_state;
u16 link_state = 0;

if (hcd->speed == HCD_USB3) {
ports = xhci->num_usb3_ports;
port_array = xhci->usb3_ports;
} else {
ports = xhci->num_usb2_ports;
port_array = xhci->usb2_ports;
}
max_ports = xhci_get_ports(hcd, &port_array);
bus_state = &xhci->bus_state[hcd_index(hcd)];

spin_lock_irqsave(&xhci->lock, flags);
Expand All @@ -420,7 +430,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
(struct usb_hub_descriptor *) buf);
break;
case GetPortStatus:
if (!wIndex || wIndex > ports)
if (!wIndex || wIndex > max_ports)
goto error;
wIndex--;
status = 0;
Expand Down Expand Up @@ -519,7 +529,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
if (wValue == USB_PORT_FEAT_LINK_STATE)
link_state = (wIndex & 0xff00) >> 3;
wIndex &= 0xff;
if (!wIndex || wIndex > ports)
if (!wIndex || wIndex > max_ports)
goto error;
wIndex--;
temp = xhci_readl(xhci, port_array[wIndex]);
Expand Down Expand Up @@ -637,7 +647,7 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
temp = xhci_readl(xhci, port_array[wIndex]);
break;
case ClearPortFeature:
if (!wIndex || wIndex > ports)
if (!wIndex || wIndex > max_ports)
goto error;
wIndex--;
temp = xhci_readl(xhci, port_array[wIndex]);
Expand Down Expand Up @@ -730,29 +740,23 @@ int xhci_hub_status_data(struct usb_hcd *hcd, char *buf)
u32 mask;
int i, retval;
struct xhci_hcd *xhci = hcd_to_xhci(hcd);
int ports;
int max_ports;
__le32 __iomem **port_array;
struct xhci_bus_state *bus_state;

if (hcd->speed == HCD_USB3) {
ports = xhci->num_usb3_ports;
port_array = xhci->usb3_ports;
} else {
ports = xhci->num_usb2_ports;
port_array = xhci->usb2_ports;
}
max_ports = xhci_get_ports(hcd, &port_array);
bus_state = &xhci->bus_state[hcd_index(hcd)];

/* Initial status is no changes */
retval = (ports + 8) / 8;
retval = (max_ports + 8) / 8;
memset(buf, 0, retval);
status = 0;

mask = PORT_CSC | PORT_PEC | PORT_OCC | PORT_PLC;

spin_lock_irqsave(&xhci->lock, flags);
/* For each port, did anything change? If so, set that bit in buf. */
for (i = 0; i < ports; i++) {
for (i = 0; i < max_ports; i++) {
temp = xhci_readl(xhci, port_array[i]);
if (temp == 0xffffffff) {
retval = -ENODEV;
Expand Down Expand Up @@ -780,15 +784,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
struct xhci_bus_state *bus_state;
unsigned long flags;

if (hcd->speed == HCD_USB3) {
max_ports = xhci->num_usb3_ports;
port_array = xhci->usb3_ports;
xhci_dbg(xhci, "suspend USB 3.0 root hub\n");
} else {
max_ports = xhci->num_usb2_ports;
port_array = xhci->usb2_ports;
xhci_dbg(xhci, "suspend USB 2.0 root hub\n");
}
max_ports = xhci_get_ports(hcd, &port_array);
bus_state = &xhci->bus_state[hcd_index(hcd)];

spin_lock_irqsave(&xhci->lock, flags);
Expand Down Expand Up @@ -873,15 +869,7 @@ int xhci_bus_resume(struct usb_hcd *hcd)
u32 temp;
unsigned long flags;

if (hcd->speed == HCD_USB3) {
max_ports = xhci->num_usb3_ports;
port_array = xhci->usb3_ports;
xhci_dbg(xhci, "resume USB 3.0 root hub\n");
} else {
max_ports = xhci->num_usb2_ports;
port_array = xhci->usb2_ports;
xhci_dbg(xhci, "resume USB 2.0 root hub\n");
}
max_ports = xhci_get_ports(hcd, &port_array);
bus_state = &xhci->bus_state[hcd_index(hcd)];

if (time_before(jiffies, bus_state->next_statechange))
Expand Down

0 comments on commit 2f2ce3b

Please sign in to comment.