From patchwork Thu Sep 10 08:21:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunfeng Yun X-Patchwork-Id: 11767079 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 472A0618 for ; Thu, 10 Sep 2020 08:33:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2150620C09 for ; Thu, 10 Sep 2020 08:33:32 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="kNTHCv3b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730154AbgIJIdY (ORCPT ); Thu, 10 Sep 2020 04:33:24 -0400 Received: from mailgw02.mediatek.com ([1.203.163.81]:22870 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1730381AbgIJIYe (ORCPT ); Thu, 10 Sep 2020 04:24:34 -0400 X-UUID: 83d501ad5656476d869246c8f3a0fce2-20200910 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=glUu4ILa56NmCzEya+FLhC/5JYoRtBGd30upHM8qMX0=; b=kNTHCv3bsP1phVyVcMnw2YdaoXCHZqhRcfa9vrGnKg8IHatDrzKu+eqZuZL2iTvAwUQ+WaCowX71PJmp1XZQ3W1UJZ2MOUaXZ+sYw3NHV2u1r/Q/KrCfAnNSTiAu1e5l3Ra50mtnxTGWRaXEZWpdkm3lTbgyZRKYZF6xMIs+zAw=; X-UUID: 83d501ad5656476d869246c8f3a0fce2-20200910 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw02.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 244888743; Thu, 10 Sep 2020 16:24:06 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Thu, 10 Sep 2020 16:24:05 +0800 Received: from localhost.localdomain (10.17.3.153) by MTKCAS06.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Thu, 10 Sep 2020 16:24:04 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Mathias Nyman , Felipe Balbi , Matthias Brugger , Douglas Anderson , Chunfeng Yun , Daniel Thompson , "Eric W. Biederman" , Lee Jones , Sumit Garg , Jann Horn , Arnd Bergmann , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , Ben Dooks , Saurav Girepunje , , , , Subject: [PATCH RESEND v3 05/11] usb: oxu210hp-hcd: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:46 +0800 Message-ID: <1599726112-4439-5-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> References: <1599726112-4439-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: C5A2AC489B45A0F990228762FA8A7204B6D8C1A944092FAC6D1DCAFFC99CC7D52000:8 X-MTK: N Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v2~v3: no changes --- drivers/usb/host/oxu210hp-hcd.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/oxu210hp-hcd.c b/drivers/usb/host/oxu210hp-hcd.c index cfa7dd2..27dbbe1 100644 --- a/drivers/usb/host/oxu210hp-hcd.c +++ b/drivers/usb/host/oxu210hp-hcd.c @@ -24,6 +24,7 @@ #include #include #include +#include #include #include @@ -748,18 +749,16 @@ static int handshake(struct oxu_hcd *oxu, 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_atomic(ptr, result, + ((result & mask) == done || + result == U32_MAX), + 1, usec); + if (result == U32_MAX) /* card removed */ + return -ENODEV; + + return ret; } /* Force HC to halt state from unknown (EHCI spec section 2.3) */