From patchwork Tue Jul 3 07:20:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai-Heng Feng X-Patchwork-Id: 938449 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=canonical.com Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41KbBy5R7mz9s29; Tue, 3 Jul 2018 17:21:14 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1faFcZ-0004HX-5U; Tue, 03 Jul 2018 07:21:07 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by huckleberry.canonical.com with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.86_2) (envelope-from ) id 1faFcU-0004EI-Tp for kernel-team@lists.ubuntu.com; Tue, 03 Jul 2018 07:21:02 +0000 Received: from [175.41.48.77] (helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1faFcU-0000M8-5a for kernel-team@lists.ubuntu.com; Tue, 03 Jul 2018 07:21:02 +0000 From: Kai-Heng Feng To: kernel-team@lists.ubuntu.com Subject: [PATCH 09/16] xhci: change xhci_test_and_clear_bit() to use new port structure Date: Tue, 3 Jul 2018 15:20:22 +0800 Message-Id: <20180703072029.14289-10-kai.heng.feng@canonical.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180703072029.14289-1-kai.heng.feng@canonical.com> References: <20180703072029.14289-1-kai.heng.feng@canonical.com> X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Mathias Nyman BugLink: https://bugs.launchpad.net/bugs/1763594 Don't use pointers to port array and port index as function parameters in xhci_test_and_clear_bit(), just use a pointer to the right port structure. xhci_test_and_clear_bit() was the last port_array user in xhci_get_port_status() and handle_port_status(), so remove the port_array from them as well. Signed-off-by: Mathias Nyman Signed-off-by: Greg Kroah-Hartman (backported from commit eaefcf246b56ec888ccbbb6b39da688166d4d4fb) Signed-off-by: Kai-Heng Feng --- drivers/usb/host/xhci-hub.c | 22 ++++++++++------------ drivers/usb/host/xhci-ring.c | 15 +++------------ drivers/usb/host/xhci.h | 4 ++-- 3 files changed, 15 insertions(+), 26 deletions(-) diff --git a/drivers/usb/host/xhci-hub.c b/drivers/usb/host/xhci-hub.c index 00490e4ada68..42b7de72b2d5 100644 --- a/drivers/usb/host/xhci-hub.c +++ b/drivers/usb/host/xhci-hub.c @@ -718,16 +718,16 @@ static void xhci_set_remote_wake_mask(struct xhci_hcd *xhci, } /* 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) +void xhci_test_and_clear_bit(struct xhci_hcd *xhci, struct xhci_port *port, + u32 port_bit) { u32 temp; - temp = readl(port_array[port_id]); + temp = readl(port->addr); if (temp & port_bit) { temp = xhci_port_state_to_neutral(temp); temp |= port_bit; - writel(temp, port_array[port_id]); + writel(temp, port->addr); } } @@ -847,8 +847,7 @@ static u32 xhci_get_ext_port_status(u32 raw_port_status, u32 port_li) */ static u32 xhci_get_port_status(struct usb_hcd *hcd, struct xhci_bus_state *bus_state, - __le32 __iomem **port_array, - u16 wIndex, u32 raw_port_status, + u16 wIndex, u32 raw_port_status, unsigned long flags) __releases(&xhci->lock) __acquires(&xhci->lock) @@ -931,8 +930,7 @@ static u32 xhci_get_port_status(struct usb_hcd *hcd, set_bit(wIndex, &bus_state->rexit_ports); - xhci_test_and_clear_bit(xhci, port_array, wIndex, - PORT_PLC); + xhci_test_and_clear_bit(xhci, port, PORT_PLC); xhci_set_link_state(xhci, port, XDEV_U0); spin_unlock_irqrestore(&xhci->lock, flags); @@ -1091,8 +1089,8 @@ int xhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue, retval = -ENODEV; break; } - status = xhci_get_port_status(hcd, bus_state, port_array, - wIndex, temp, flags); + status = xhci_get_port_status(hcd, bus_state, wIndex, temp, + flags); if (status == 0xffffffff) goto error; @@ -1664,7 +1662,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) for_each_set_bit(port_index, &bus_state->bus_suspended, BITS_PER_LONG) { /* Clear PLC to poll it later for U0 transition */ - xhci_test_and_clear_bit(xhci, port_array, port_index, + xhci_test_and_clear_bit(xhci, ports[port_index], PORT_PLC); xhci_set_link_state(xhci, ports[port_index], XDEV_U0); } @@ -1679,7 +1677,7 @@ int xhci_bus_resume(struct usb_hcd *hcd) port_index); continue; } - xhci_test_and_clear_bit(xhci, port_array, port_index, PORT_PLC); + xhci_test_and_clear_bit(xhci, ports[port_index], PORT_PLC); slot_id = xhci_find_slot_id_by_port(hcd, xhci, port_index + 1); if (slot_id) xhci_ring_device(xhci, slot_id); diff --git a/drivers/usb/host/xhci-ring.c b/drivers/usb/host/xhci-ring.c index 2bd34a2cfad5..01f5aed3271a 100644 --- a/drivers/usb/host/xhci-ring.c +++ b/drivers/usb/host/xhci-ring.c @@ -1526,7 +1526,6 @@ static void handle_port_status(struct xhci_hcd *xhci, int slot_id; unsigned int hcd_portnum; struct xhci_bus_state *bus_state; - __le32 __iomem **port_array; bool bogus_port_status = false; struct xhci_port *port; @@ -1554,11 +1553,6 @@ static void handle_port_status(struct xhci_hcd *xhci, hcd = port->rhub->hcd; bus_state = &xhci->bus_state[hcd_index(hcd)]; - if (hcd->speed >= HCD_USB3) - port_array = xhci->usb3_ports; - else - port_array = xhci->usb2_ports; - hcd_portnum = port->hcd_portnum; portsc = readl(port->addr); @@ -1588,8 +1582,7 @@ static void handle_port_status(struct xhci_hcd *xhci, * device and host initiated resume. */ bus_state->port_remote_wakeup |= 1 << hcd_portnum; - xhci_test_and_clear_bit(xhci, port_array, - hcd_portnum, PORT_PLC); + xhci_test_and_clear_bit(xhci, port, PORT_PLC); xhci_set_link_state(xhci, port, XDEV_U0); /* Need to wait until the next link state change * indicates the device is actually in U0. @@ -1627,8 +1620,7 @@ static void handle_port_status(struct xhci_hcd *xhci, xhci_ring_device(xhci, slot_id); if (bus_state->port_remote_wakeup & (1 << hcd_portnum)) { bus_state->port_remote_wakeup &= ~(1 << hcd_portnum); - xhci_test_and_clear_bit(xhci, port_array, - hcd_portnum, PORT_PLC); + xhci_test_and_clear_bit(xhci, port, PORT_PLC); usb_wakeup_notification(hcd->self.root_hub, hcd_portnum + 1); bogus_port_status = true; @@ -1650,8 +1642,7 @@ static void handle_port_status(struct xhci_hcd *xhci, } if (hcd->speed < HCD_USB3) - xhci_test_and_clear_bit(xhci, port_array, hcd_portnum, - PORT_PLC); + xhci_test_and_clear_bit(xhci, port, PORT_PLC); cleanup: /* Update event ring dequeue pointer before dropping the lock */ diff --git a/drivers/usb/host/xhci.h b/drivers/usb/host/xhci.h index cc21282c8bac..abd712e4acf9 100644 --- a/drivers/usb/host/xhci.h +++ b/drivers/usb/host/xhci.h @@ -2102,8 +2102,8 @@ unsigned int count_trbs(u64 addr, u64 len); /* xHCI roothub code */ void xhci_set_link_state(struct xhci_hcd *xhci, struct xhci_port *port, u32 link_state); -void xhci_test_and_clear_bit(struct xhci_hcd *xhci, __le32 __iomem **port_array, - int port_id, u32 port_bit); +void xhci_test_and_clear_bit(struct xhci_hcd *xhci, struct xhci_port *port, + 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);