Function xhci_readl() is used to read 32bit xHC registers residing in MMIO
address space. It takes as first argument a pointer to the xhci_hcd although
it does not use it because internally it simply calls readl. This creates
an illusion that xhci_readl() is an xhci specific function that has to be
called in a context where a pointer to xhci_hcd is available.
This patch replaces calls to xhci_readl() with calls to readl() in xhci.c.
This is done so that xhci_readl() can be removed completely and code can
become more straightforward.

Signed-off-by: Xenia Ragiadakou <burzalod...@gmail.com>
---
 drivers/usb/host/xhci.c | 92 ++++++++++++++++++++++++-------------------------
 1 file changed, 46 insertions(+), 46 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 9f22ddf..6f47c2b 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -60,7 +60,7 @@ int xhci_handshake(struct xhci_hcd *xhci, void __iomem *ptr,
        u32     result;
 
        do {
-               result = xhci_readl(xhci, ptr);
+               result = readl(ptr);
                if (result == ~(u32)0)          /* card removed */
                        return -ENODEV;
                result &= mask;
@@ -82,11 +82,11 @@ void xhci_quiesce(struct xhci_hcd *xhci)
        u32 mask;
 
        mask = ~(XHCI_IRQS);
-       halted = xhci_readl(xhci, &xhci->op_regs->status) & STS_HALT;
+       halted = readl(&xhci->op_regs->status) & STS_HALT;
        if (!halted)
                mask &= ~CMD_RUN;
 
-       cmd = xhci_readl(xhci, &xhci->op_regs->command);
+       cmd = readl(&xhci->op_regs->command);
        cmd &= mask;
        xhci_writel(xhci, cmd, &xhci->op_regs->command);
 }
@@ -124,7 +124,7 @@ static int xhci_start(struct xhci_hcd *xhci)
        u32 temp;
        int ret;
 
-       temp = xhci_readl(xhci, &xhci->op_regs->command);
+       temp = readl(&xhci->op_regs->command);
        temp |= (CMD_RUN);
        xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Turn on HC, cmd = 0x%x.",
                        temp);
@@ -158,14 +158,14 @@ int xhci_reset(struct xhci_hcd *xhci)
        u32 state;
        int ret, i;
 
-       state = xhci_readl(xhci, &xhci->op_regs->status);
+       state = readl(&xhci->op_regs->status);
        if ((state & STS_HALT) == 0) {
                xhci_warn(xhci, "Host controller not halted, aborting 
reset.\n");
                return 0;
        }
 
        xhci_dbg_trace(xhci, trace_xhci_dbg_init, "// Reset the HC");
-       command = xhci_readl(xhci, &xhci->op_regs->command);
+       command = readl(&xhci->op_regs->command);
        command |= CMD_RESET;
        xhci_writel(xhci, command, &xhci->op_regs->command);
 
@@ -422,7 +422,7 @@ static void compliance_mode_recovery(unsigned long arg)
        xhci = (struct xhci_hcd *)arg;
 
        for (i = 0; i < xhci->num_usb3_ports; i++) {
-               temp = xhci_readl(xhci, xhci->usb3_ports[i]);
+               temp = readl(xhci->usb3_ports[i]);
                if ((temp & PORT_PLS_MASK) == USB_SS_PORT_LS_COMP_MOD) {
                        /*
                         * Compliance Mode Detected. Letting USB Core
@@ -611,19 +611,19 @@ int xhci_run(struct usb_hcd *hcd)
 
        xhci_dbg_trace(xhci, trace_xhci_dbg_init,
                        "// Set the interrupt modulation register");
-       temp = xhci_readl(xhci, &xhci->ir_set->irq_control);
+       temp = readl(&xhci->ir_set->irq_control);
        temp &= ~ER_IRQ_INTERVAL_MASK;
        temp |= (u32) 160;
        xhci_writel(xhci, temp, &xhci->ir_set->irq_control);
 
        /* Set the HCD state before we enable the irqs */
-       temp = xhci_readl(xhci, &xhci->op_regs->command);
+       temp = readl(&xhci->op_regs->command);
        temp |= (CMD_EIE);
        xhci_dbg_trace(xhci, trace_xhci_dbg_init,
                        "// Enable interrupts, cmd = 0x%x.", temp);
        xhci_writel(xhci, temp, &xhci->op_regs->command);
 
-       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+       temp = readl(&xhci->ir_set->irq_pending);
        xhci_dbg_trace(xhci, trace_xhci_dbg_init,
                        "// Enabling event ring interrupter %p by writing 0x%x 
to irq_pending",
                        xhci->ir_set, (unsigned int) ER_IRQ_ENABLE(temp));
@@ -698,9 +698,9 @@ void xhci_stop(struct usb_hcd *hcd)
 
        xhci_dbg_trace(xhci, trace_xhci_dbg_init,
                        "// Disabling event ring interrupts");
-       temp = xhci_readl(xhci, &xhci->op_regs->status);
+       temp = readl(&xhci->op_regs->status);
        xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status);
-       temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+       temp = readl(&xhci->ir_set->irq_pending);
        xhci_writel(xhci, ER_IRQ_DISABLE(temp),
                        &xhci->ir_set->irq_pending);
        xhci_print_ir_set(xhci, 0);
@@ -709,7 +709,7 @@ void xhci_stop(struct usb_hcd *hcd)
        xhci_mem_cleanup(xhci);
        xhci_dbg_trace(xhci, trace_xhci_dbg_init,
                        "xhci_stop completed - status = %x",
-                       xhci_readl(xhci, &xhci->op_regs->status));
+                       readl(&xhci->op_regs->status));
 }
 
 /*
@@ -736,21 +736,21 @@ void xhci_shutdown(struct usb_hcd *hcd)
 
        xhci_dbg_trace(xhci, trace_xhci_dbg_init,
                        "xhci_shutdown completed - status = %x",
-                       xhci_readl(xhci, &xhci->op_regs->status));
+                       readl(&xhci->op_regs->status));
 }
 
 #ifdef CONFIG_PM
 static void xhci_save_registers(struct xhci_hcd *xhci)
 {
-       xhci->s3.command = xhci_readl(xhci, &xhci->op_regs->command);
-       xhci->s3.dev_nt = xhci_readl(xhci, &xhci->op_regs->dev_notification);
+       xhci->s3.command = readl(&xhci->op_regs->command);
+       xhci->s3.dev_nt = readl(&xhci->op_regs->dev_notification);
        xhci->s3.dcbaa_ptr = xhci_read_64(xhci, &xhci->op_regs->dcbaa_ptr);
-       xhci->s3.config_reg = xhci_readl(xhci, &xhci->op_regs->config_reg);
-       xhci->s3.erst_size = xhci_readl(xhci, &xhci->ir_set->erst_size);
+       xhci->s3.config_reg = readl(&xhci->op_regs->config_reg);
+       xhci->s3.erst_size = readl(&xhci->ir_set->erst_size);
        xhci->s3.erst_base = xhci_read_64(xhci, &xhci->ir_set->erst_base);
        xhci->s3.erst_dequeue = xhci_read_64(xhci, &xhci->ir_set->erst_dequeue);
-       xhci->s3.irq_pending = xhci_readl(xhci, &xhci->ir_set->irq_pending);
-       xhci->s3.irq_control = xhci_readl(xhci, &xhci->ir_set->irq_control);
+       xhci->s3.irq_pending = readl(&xhci->ir_set->irq_pending);
+       xhci->s3.irq_control = readl(&xhci->ir_set->irq_control);
 }
 
 static void xhci_restore_registers(struct xhci_hcd *xhci)
@@ -858,7 +858,7 @@ int xhci_suspend(struct xhci_hcd *xhci)
        /* skipped assuming that port suspend has done */
 
        /* step 2: clear Run/Stop bit */
-       command = xhci_readl(xhci, &xhci->op_regs->command);
+       command = readl(&xhci->op_regs->command);
        command &= ~CMD_RUN;
        xhci_writel(xhci, command, &xhci->op_regs->command);
        if (xhci_handshake(xhci, &xhci->op_regs->status,
@@ -873,7 +873,7 @@ int xhci_suspend(struct xhci_hcd *xhci)
        xhci_save_registers(xhci);
 
        /* step 4: set CSS flag */
-       command = xhci_readl(xhci, &xhci->op_regs->command);
+       command = readl(&xhci->op_regs->command);
        command |= CMD_CSS;
        xhci_writel(xhci, command, &xhci->op_regs->command);
        if (xhci_handshake(xhci, &xhci->op_regs->status,
@@ -939,7 +939,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
                xhci_set_cmd_ring_deq(xhci);
                /* step 3: restore state and start state*/
                /* step 3: set CRS flag */
-               command = xhci_readl(xhci, &xhci->op_regs->command);
+               command = readl(&xhci->op_regs->command);
                command |= CMD_CRS;
                xhci_writel(xhci, command, &xhci->op_regs->command);
                if (xhci_handshake(xhci, &xhci->op_regs->status,
@@ -948,7 +948,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
                        spin_unlock_irq(&xhci->lock);
                        return -ETIMEDOUT;
                }
-               temp = xhci_readl(xhci, &xhci->op_regs->status);
+               temp = readl(&xhci->op_regs->status);
        }
 
        /* If restore operation fails, re-initialize the HC during resume */
@@ -972,9 +972,9 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
                xhci_cleanup_msix(xhci);
 
                xhci_dbg(xhci, "// Disabling event ring interrupts\n");
-               temp = xhci_readl(xhci, &xhci->op_regs->status);
+               temp = readl(&xhci->op_regs->status);
                xhci_writel(xhci, temp & ~STS_EINT, &xhci->op_regs->status);
-               temp = xhci_readl(xhci, &xhci->ir_set->irq_pending);
+               temp = readl(&xhci->ir_set->irq_pending);
                xhci_writel(xhci, ER_IRQ_DISABLE(temp),
                                &xhci->ir_set->irq_pending);
                xhci_print_ir_set(xhci, 0);
@@ -982,7 +982,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
                xhci_dbg(xhci, "cleaning up memory\n");
                xhci_mem_cleanup(xhci);
                xhci_dbg(xhci, "xhci_stop completed - status = %x\n",
-                           xhci_readl(xhci, &xhci->op_regs->status));
+                           readl(&xhci->op_regs->status));
 
                /* USB core calls the PCI reinit and start functions twice:
                 * first with the primary HCD, and then with the secondary HCD.
@@ -1011,7 +1011,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
        }
 
        /* step 4: set Run/Stop bit */
-       command = xhci_readl(xhci, &xhci->op_regs->command);
+       command = readl(&xhci->op_regs->command);
        command |= CMD_RUN;
        xhci_writel(xhci, command, &xhci->op_regs->command);
        xhci_handshake(xhci, &xhci->op_regs->status, STS_HALT,
@@ -1452,7 +1452,7 @@ int xhci_urb_dequeue(struct usb_hcd *hcd, struct urb 
*urb, int status)
        ret = usb_hcd_check_unlink_urb(hcd, urb, status);
        if (ret || !urb->hcpriv)
                goto done;
-       temp = xhci_readl(xhci, &xhci->op_regs->status);
+       temp = readl(&xhci->op_regs->status);
        if (temp == 0xffffffff || (xhci->xhc_state & XHCI_STATE_HALTED)) {
                xhci_dbg_trace(xhci, trace_xhci_dbg_cancel_urb,
                                "HW died, freeing TD.");
@@ -3583,7 +3583,7 @@ void xhci_free_dev(struct usb_hcd *hcd, struct usb_device 
*udev)
 
        spin_lock_irqsave(&xhci->lock, flags);
        /* Don't disable the slot if the host controller is dead. */
-       state = xhci_readl(xhci, &xhci->op_regs->status);
+       state = readl(&xhci->op_regs->status);
        if (state == 0xffffffff || (xhci->xhc_state & XHCI_STATE_DYING) ||
                        (xhci->xhc_state & XHCI_STATE_HALTED)) {
                xhci_free_virt_device(xhci, udev->slot_id);
@@ -4082,12 +4082,12 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd 
*hcd,
                        PORT_L1S_MASK, PORT_L1S_SUCCESS, 125);
        if (ret != -ETIMEDOUT) {
                /* enter L1 successfully */
-               temp = xhci_readl(xhci, addr);
+               temp = readl(addr);
                xhci_dbg(xhci, "port %d entered L1 state, port status 0x%x\n",
                                port_num, temp);
                ret = 0;
        } else {
-               temp = xhci_readl(xhci, pm_addr);
+               temp = readl(pm_addr);
                xhci_dbg(xhci, "port %d software lpm failed, L1 status %d\n",
                                port_num, temp & PORT_L1S_MASK);
                ret = -EINVAL;
@@ -4105,7 +4105,7 @@ static int xhci_usb2_software_lpm_test(struct usb_hcd 
*hcd,
 
        /* Check PORTSC to make sure the device is in the right state */
        if (!ret) {
-               temp = xhci_readl(xhci, addr);
+               temp = readl(addr);
                xhci_dbg(xhci, "resumed port %d status 0x%x\n", port_num, temp);
                if (!(temp & PORT_CONNECT) || !(temp & PORT_PE) ||
                                (temp & PORT_PLS_MASK) != XDEV_U0) {
@@ -4163,7 +4163,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
        port_array = xhci->usb2_ports;
        port_num = udev->portnum - 1;
        pm_addr = port_array[port_num] + PORTPMSC;
-       pm_val = xhci_readl(xhci, pm_addr);
+       pm_val = readl(pm_addr);
        hlpm_addr = port_array[port_num] + PORTHLPMC;
        field = le32_to_cpu(udev->bos->ext_cap->bmAttributes);
 
@@ -4205,7 +4205,7 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
                        hlpm_val = xhci_calculate_usb2_hw_lpm_params(udev);
                        xhci_writel(xhci, hlpm_val, hlpm_addr);
                        /* flush write */
-                       xhci_readl(xhci, hlpm_addr);
+                       readl(hlpm_addr);
                } else {
                        hird = xhci_calculate_hird_besl(xhci, udev);
                }
@@ -4213,16 +4213,16 @@ int xhci_set_usb2_hardware_lpm(struct usb_hcd *hcd,
                pm_val &= ~PORT_HIRD_MASK;
                pm_val |= PORT_HIRD(hird) | PORT_RWE;
                xhci_writel(xhci, pm_val, pm_addr);
-               pm_val = xhci_readl(xhci, pm_addr);
+               pm_val = readl(pm_addr);
                pm_val |= PORT_HLE;
                xhci_writel(xhci, pm_val, pm_addr);
                /* flush write */
-               xhci_readl(xhci, pm_addr);
+               readl(pm_addr);
        } else {
                pm_val &= ~(PORT_HLE | PORT_RWE | PORT_HIRD_MASK);
                xhci_writel(xhci, pm_val, pm_addr);
                /* flush write */
-               xhci_readl(xhci, pm_addr);
+               readl(pm_addr);
                if (udev->usb2_hw_lpm_besl_capable) {
                        spin_unlock_irqrestore(&xhci->lock, flags);
                        mutex_lock(hcd->bandwidth_mutex);
@@ -4823,7 +4823,7 @@ int xhci_get_frame(struct usb_hcd *hcd)
 {
        struct xhci_hcd *xhci = hcd_to_xhci(hcd);
        /* EHCI mods by the periodic size.  Why? */
-       return xhci_readl(xhci, &xhci->run_regs->microframe_index) >> 3;
+       return readl(&xhci->run_regs->microframe_index) >> 3;
 }
 
 int xhci_gen_setup(struct usb_hcd *hcd, xhci_get_quirks_t get_quirks)
@@ -4867,16 +4867,16 @@ int xhci_gen_setup(struct usb_hcd *hcd, 
xhci_get_quirks_t get_quirks)
 
        xhci->cap_regs = hcd->regs;
        xhci->op_regs = hcd->regs +
-               HC_LENGTH(xhci_readl(xhci, &xhci->cap_regs->hc_capbase));
+               HC_LENGTH(readl(&xhci->cap_regs->hc_capbase));
        xhci->run_regs = hcd->regs +
-               (xhci_readl(xhci, &xhci->cap_regs->run_regs_off) & RTSOFF_MASK);
+               (readl(&xhci->cap_regs->run_regs_off) & RTSOFF_MASK);
        /* Cache read-only capability registers */
-       xhci->hcs_params1 = xhci_readl(xhci, &xhci->cap_regs->hcs_params1);
-       xhci->hcs_params2 = xhci_readl(xhci, &xhci->cap_regs->hcs_params2);
-       xhci->hcs_params3 = xhci_readl(xhci, &xhci->cap_regs->hcs_params3);
-       xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hc_capbase);
+       xhci->hcs_params1 = readl(&xhci->cap_regs->hcs_params1);
+       xhci->hcs_params2 = readl(&xhci->cap_regs->hcs_params2);
+       xhci->hcs_params3 = readl(&xhci->cap_regs->hcs_params3);
+       xhci->hcc_params = readl(&xhci->cap_regs->hc_capbase);
        xhci->hci_version = HC_VERSION(xhci->hcc_params);
-       xhci->hcc_params = xhci_readl(xhci, &xhci->cap_regs->hcc_params);
+       xhci->hcc_params = readl(&xhci->cap_regs->hcc_params);
        xhci_print_registers(xhci);
 
        get_quirks(dev, xhci);
-- 
1.8.3.4

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to