Received: by 2002:ac0:8c8e:0:0:0:0:0 with SMTP id r14csp7703ima; Wed, 6 Feb 2019 16:04:03 -0800 (PST) X-Google-Smtp-Source: AHgI3IY8iroMVZYxdDTIy+K1Z7ydeyM6QNFFdD3nr2V+Ayv4njzpjx03RkmUmR192ym31O9OE91C X-Received: by 2002:a62:425b:: with SMTP id p88mr13369628pfa.137.1549497843299; Wed, 06 Feb 2019 16:04:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549497843; cv=none; d=google.com; s=arc-20160816; b=Ih10zEZXFmdnnMGoYt6kMFj1ZYna7qrRRNPzxAdNxiFeM24+aMC5WvN9r1rox0dvcu lqMx7bQizvNJetLi3uTjP7AntVPqQhrrIJhjM6tppjqlolOnN7pu0XeWdZv/YbjK67Tf Y70qL9lUPoIsUEoLw3ulwq69G4qB261O0hvkEWFgG6Y1pp/l7TLAX4nEHJmmgQDjzosK HhZ+zB7Vd00SdC7vl1QpZP+ar8O6nt2tuw7JlU2y8vQp33iCFrVUTgFW9XGnBoEOJW8m bBuSO0qOlEqAUHajfpIW3pWkFtpTh4g70qaesPZMWkyohh/HGp7ClVo/A2GecjolZh6h 9sHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=p6Y2SMTy/DLvibQn4rvUxUkItMt4BibJMOVwHTLlWdU=; b=EUe+n2VRehLuGsfn5rJQ1C59/rMcAA0qHAB+toV9hXypqIqisQBMPyVTYpWx3GZ+JQ njjrAzzV7N0XUjZsWfrFBSBAScMYjX6ZLNfzs2QrMoSBr7mtWja2ENnA705Y1wT0UjKE hjbWSVEC2LY2hNA1n+cn78kwwlyjtS6AJ59ENgg/PP70rhLkLcK507ytds7QV8OsjsoL vw3NmhfCHvuaiyMgYVYTf+a+59Fq+Awr9YGoeEw25Fc1hUqV+DAg5cd4HGsyiK8zgLW8 1MEdeP9F3oiAwo4KRzwxL2XNFS55Oeig12NnYnCEqHAdSBdZu1Dg2HU6w7/rmTD8bLsl U8Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bn4j45vM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d188si6746120pgc.97.2019.02.06.16.03.40; Wed, 06 Feb 2019 16:04:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Bn4j45vM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726715AbfBGADY (ORCPT + 99 others); Wed, 6 Feb 2019 19:03:24 -0500 Received: from mail-pg1-f196.google.com ([209.85.215.196]:38247 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725959AbfBGADY (ORCPT ); Wed, 6 Feb 2019 19:03:24 -0500 Received: by mail-pg1-f196.google.com with SMTP id g189so3679895pgc.5; Wed, 06 Feb 2019 16:03:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p6Y2SMTy/DLvibQn4rvUxUkItMt4BibJMOVwHTLlWdU=; b=Bn4j45vMnDeJ187Pc028HJG8OhN+ineByup/7oFOJzwXTK29kxU822HUPNS5A0NzBf 98s+pbbGafgdmMfcfWQ/e49gsPCNWKAQZawO/BVDYtSVtGpsLza/e1UJGtImNiYVZH0B v0W7pD8R6IxVFQHlW5ViFFecmQS102F1HurvmVo2z2Spdhh+Ca0Xj9XzUaj+ne6j9uF/ +hEpeUS7QRw1GFrlZhHK6/UCnl11fZic7oFpbchY9Ufrrye1fZHXBpp0lri8KDBVdA+H ZP+IjMibkya85ebNoVcfbGM0INBXCRw01H8v/VFsWpVbutFbzhCA3vGXHh8chzAxZd05 2kKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=p6Y2SMTy/DLvibQn4rvUxUkItMt4BibJMOVwHTLlWdU=; b=ZSzuudNG79tIiGyXSKS3ZcnWeU+SHNjNRrOtdVHvBcNZEWHob23xUB021V3yU03DNC pKTWVLMk3CRkiOMlxHm5vC5i2CuhOytPJOSI/MibCnI+1UgvwnRlNmc4mzoJofzHFlgA vi1dUauB9dTl9cFWix2zmy8ikCUuKFRMqHxkz4ne72X7mcGw/VPiHhmgD9x1oSFJ1y/r bMFu7i9dJqpnpLZMlQZAq2w+CigZwrn3/Sfav9c8YaAmpuPRnxc3fN5AZJEidOA+3xZs H61XPEkbxziIRJiSEMuKHtZ6P2FWg9dQlq+NjFyN3Zitvap0xIZAT95cS5HDHqtgw/mO Yx7w== X-Gm-Message-State: AHQUAuaiF9CgZAKggosRIgj0gBbmUdiZOmJR81jzbdtSwuvUU5+4h6Ss dJetd9f+iMqNSCHdpHYV4DwozXb6 X-Received: by 2002:a63:5e43:: with SMTP id s64mr12165266pgb.101.1549497802790; Wed, 06 Feb 2019 16:03:22 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id p2sm11615974pgc.94.2019.02.06.16.03.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 06 Feb 2019 16:03:21 -0800 (PST) From: Andrey Smirnov To: linux-usb@vger.kernel.org Cc: Andrey Smirnov , Mathias Nyman , Greg Kroah-Hartman , linux-kernel@vger.kernel.org Subject: [PATCH] xhci: Convert xhci_handshake() to use readl_poll_timeout() Date: Wed, 6 Feb 2019 16:03:08 -0800 Message-Id: <20190207000308.7051-1-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Xhci_handshake() implements the algorithm already captured by readl_poll_timeout(). Convert the former to use the latter to avoid repetition. Signed-off-by: Andrey Smirnov Cc: Mathias Nyman Cc: Greg Kroah-Hartman Cc: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org --- drivers/usb/host/xhci.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c index 005e65922608..1b5306001340 100644 --- a/drivers/usb/host/xhci.c +++ b/drivers/usb/host/xhci.c @@ -9,6 +9,7 @@ */ #include +#include #include #include #include @@ -52,7 +53,6 @@ static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring) return false; } -/* TODO: copied from ehci-hcd.c - can this be refactored? */ /* * xhci_handshake - spin reading hc until handshake completes or fails * @ptr: address of hc register to be read @@ -69,18 +69,16 @@ static bool td_on_ring(struct xhci_td *td, struct xhci_ring *ring) int xhci_handshake(void __iomem *ptr, u32 mask, u32 done, int usec) { u32 result; + int ret; - do { - result = readl(ptr); - if (result == ~(u32)0) /* card removed */ - return -ENODEV; - result &= mask; - if (result == done) - return 0; - udelay(1); - usec--; - } while (usec > 0); - return -ETIMEDOUT; + ret = readl_poll_timeout(ptr, result, + (result & mask) == done || + result == U32_MAX, + 1, usec); + if (result == U32_MAX) /* card removed */ + return -ENODEV; + + return ret; } /* -- 2.20.1