Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb: xhci-rcar: convert to readl_poll_timeout_atomic()

Use readl_poll_timeout_atomic() to simplify code

Cc: Mathias Nyman <mathias.nyman@linux.intel.com>
Cc: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Link: https://lore.kernel.org/r/1600668815-12135-4-git-send-email-chunfeng.yun@mediatek.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Chunfeng Yun and committed by
Greg Kroah-Hartman
8469ab98 eeae3afb

+12 -31
+12 -31
drivers/usb/host/xhci-rcar.c
··· 6 6 */ 7 7 8 8 #include <linux/firmware.h> 9 + #include <linux/iopoll.h> 9 10 #include <linux/module.h> 10 11 #include <linux/platform_device.h> 11 12 #include <linux/of.h> ··· 128 127 void __iomem *regs = hcd->regs; 129 128 struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); 130 129 const struct firmware *fw; 131 - int retval, index, j, time; 132 - int timeout = 10000; 130 + int retval, index, j; 133 131 u32 data, val, temp; 134 132 u32 quirks = 0; 135 133 const struct soc_device_attribute *attr; ··· 166 166 temp |= RCAR_USB3_DL_CTRL_FW_SET_DATA0; 167 167 writel(temp, regs + RCAR_USB3_DL_CTRL); 168 168 169 - for (time = 0; time < timeout; time++) { 170 - val = readl(regs + RCAR_USB3_DL_CTRL); 171 - if ((val & RCAR_USB3_DL_CTRL_FW_SET_DATA0) == 0) 172 - break; 173 - udelay(1); 174 - } 175 - if (time == timeout) { 176 - retval = -ETIMEDOUT; 169 + retval = readl_poll_timeout_atomic(regs + RCAR_USB3_DL_CTRL, 170 + val, !(val & RCAR_USB3_DL_CTRL_FW_SET_DATA0), 171 + 1, 10000); 172 + if (retval < 0) 177 173 break; 178 - } 179 174 } 180 175 181 176 temp = readl(regs + RCAR_USB3_DL_CTRL); 182 177 temp &= ~RCAR_USB3_DL_CTRL_ENABLE; 183 178 writel(temp, regs + RCAR_USB3_DL_CTRL); 184 179 185 - for (time = 0; time < timeout; time++) { 186 - val = readl(regs + RCAR_USB3_DL_CTRL); 187 - if (val & RCAR_USB3_DL_CTRL_FW_SUCCESS) { 188 - retval = 0; 189 - break; 190 - } 191 - udelay(1); 192 - } 193 - if (time == timeout) 194 - retval = -ETIMEDOUT; 180 + retval = readl_poll_timeout_atomic((regs + RCAR_USB3_DL_CTRL), 181 + val, val & RCAR_USB3_DL_CTRL_FW_SUCCESS, 1, 10000); 195 182 196 183 release_firmware(fw); 197 184 ··· 187 200 188 201 static bool xhci_rcar_wait_for_pll_active(struct usb_hcd *hcd) 189 202 { 190 - int timeout = 1000; 203 + int retval; 191 204 u32 val, mask = RCAR_USB3_AXH_STA_PLL_ACTIVE_MASK; 192 205 193 - while (timeout > 0) { 194 - val = readl(hcd->regs + RCAR_USB3_AXH_STA); 195 - if ((val & mask) == mask) 196 - return true; 197 - udelay(1); 198 - timeout--; 199 - } 200 - 201 - return false; 206 + retval = readl_poll_timeout_atomic(hcd->regs + RCAR_USB3_AXH_STA, 207 + val, (val & mask) == mask, 1, 1000); 208 + return !retval; 202 209 } 203 210 204 211 /* This function needs to initialize a "phy" of usb before */