xHCI: test and clear RWC bit
authorAndiry Xu <andiry.xu@amd.com>
Fri, 23 Sep 2011 21:19:49 +0000 (14:19 -0700)
committerGreg Kroah-Hartman <gregkh@suse.de>
Mon, 26 Sep 2011 22:51:09 +0000 (15:51 -0700)
Introduce xhci_test_and_clear_bit() to clear RWC bit in PORTSC register.

Signed-off-by: Andiry Xu <andiry.xu@amd.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/host/xhci-hub.c
drivers/usb/host/xhci-ring.c
drivers/usb/host/xhci.h

index ef03c18a0128b4b482f4ff897df21d6d455b45af..d7be6d7324d3b18a7ae7c14375e474f2d9635ed2 100644 (file)
@@ -404,6 +404,20 @@ void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array,
        xhci_writel(xhci, temp, port_array[port_id]);
 }
 
+/* Test and clear port RWC bit */
+void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array,
+                               int port_id, u32 port_bit)
+{
+       u32 temp;
+
+       temp = xhci_readl(xhci, port_array[port_id]);
+       if (temp & port_bit) {
+               temp = xhci_port_state_to_neutral(temp);
+               temp |= port_bit;
+               xhci_writel(xhci, temp, port_array[port_id]);
+       }
+}
+
 int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
                u16 wIndex, char *buf, u16 wLength)
 {
@@ -924,12 +938,8 @@ int xhci_bus_resume(struct usb_hcd *hcd)
                        spin_lock_irqsave(&xhci->lock, flags);
 
                        /* Clear PLC */
-                       temp = xhci_readl(xhci, port_array[port_index]);
-                       if (temp & PORT_PLC) {
-                               temp = xhci_port_state_to_neutral(temp);
-                               temp |= PORT_PLC;
-                               xhci_writel(xhci, temp, port_array[port_index]);
-                       }
+                       xhci_test_and_clear_bit(xhci, port_array, port_index,
+                                               PORT_PLC);
 
                        slot_id = xhci_find_slot_id_by_port(hcd,
                                        xhci, port_index + 1);
index 0ef4f20c7f41df104aebd2f0f01b20bdfd7d4afd..30b3577816712789db517e795bbea2442660c3ea 100644 (file)
@@ -1340,10 +1340,8 @@ static void handle_port_status(struct xhci_hcd *xhci,
                        xhci_ring_device(xhci, slot_id);
                        xhci_dbg(xhci, "resume SS port %d finished\n", port_id);
                        /* Clear PORT_PLC */
-                       temp = xhci_readl(xhci, port_array[faked_port_index]);
-                       temp = xhci_port_state_to_neutral(temp);
-                       temp |= PORT_PLC;
-                       xhci_writel(xhci, temp, port_array[faked_port_index]);
+                       xhci_test_and_clear_bit(xhci, port_array,
+                                               faked_port_index, PORT_PLC);
                } else {
                        xhci_dbg(xhci, "resume HS port %d\n", port_id);
                        bus_state->resume_done[faked_port_index] = jiffies +
index 92eba69b92396e50de1e28ae55017233bc02b8ab..fa921cbbe87271d2e71c01a792ed24cf4ea6e037 100644 (file)
@@ -1719,6 +1719,8 @@ void xhci_ring_ep_doorbell(struct xhci_hcd *xhci, unsigned int slot_id,
 /* xHCI roothub code */
 void xhci_set_link_state(struct xhci_hcd *xhci, __le32 __iomem **port_array,
                                int port_id, u32 link_state);
+void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array,
+                               int port_id, u32 port_bit);
 int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex,
                char *buf, u16 wLength);
 int xhci_hub_status_data(struct usb_hcd *hcd, char *buf);