From patchwork Wed Aug 19 12:41:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chunfeng Yun X-Patchwork-Id: 258825 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, MIME_BASE64_TEXT, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, UNPARSEABLE_RELAY,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A069C433DF for ; Wed, 19 Aug 2020 12:44:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D761C206FA for ; Wed, 19 Aug 2020 12:44:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="QazGoteN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728451AbgHSMoJ (ORCPT ); Wed, 19 Aug 2020 08:44:09 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:23905 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728281AbgHSMnC (ORCPT ); Wed, 19 Aug 2020 08:43:02 -0400 X-UUID: 3049c8ad1f5446a8874adc130c91897b-20200819 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=8uPUV+WuJUk2y2D4BlVGYPxJs4zQfi1SnztFfLAGohI=; b=QazGoteNiwD18kEomorQZ0EOcrtmDC/HfBdmV1SD7JbVHnTElOLkfCf5826y4qQxXBPbVKbumnV9mDnv3FU24mcEba0woY3ef5IIM0VjuamST7st+GsuzdqClU5c07Dc3EEYRQfLglN2JldmHngr93KQfgeGsAlJCXP8/S5nZOk=; X-UUID: 3049c8ad1f5446a8874adc130c91897b-20200819 Received: from mtkcas32.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLS) with ESMTP id 1013727161; Wed, 19 Aug 2020 20:42:54 +0800 Received: from mtkcas08.mediatek.inc (172.21.101.126) by MTKMBS31DR.mediatek.inc (172.27.6.102) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Wed, 19 Aug 2020 20:42:52 +0800 Received: from localhost.localdomain (10.17.3.153) by mtkcas08.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Wed, 19 Aug 2020 20:42:51 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman CC: Felipe Balbi , Matthias Brugger , Chunfeng Yun , , , , , Lee Jones Subject: [PATCH 09/10] usb: phy: phy-mv-usb: convert to readl_poll_timeout_atomic() Date: Wed, 19 Aug 2020 20:41:04 +0800 Message-ID: <1597840865-26631-9-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1597840865-26631-1-git-send-email-chunfeng.yun@mediatek.com> References: <1597840865-26631-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 880C2D39F7C81EB325277EEE0174E037DFB900233850FB14E9242C8AAB137E272000: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 --- drivers/usb/phy/phy-mv-usb.c | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) -- 1.9.1 diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index ce767ec..008ed58 100644 --- a/drivers/usb/phy/phy-mv-usb.c +++ b/drivers/usb/phy/phy-mv-usb.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include #include @@ -135,8 +136,8 @@ static int mv_otg_set_timer(struct mv_otg *mvotg, unsigned int id, static int mv_otg_reset(struct mv_otg *mvotg) { - unsigned int loops; u32 tmp; + int ret; /* Stop the controller */ tmp = readl(&mvotg->op_regs->usbcmd); @@ -146,15 +147,12 @@ static int mv_otg_reset(struct mv_otg *mvotg) /* Reset the controller to get default values */ writel(USBCMD_CTRL_RESET, &mvotg->op_regs->usbcmd); - loops = 500; - while (readl(&mvotg->op_regs->usbcmd) & USBCMD_CTRL_RESET) { - if (loops == 0) { - dev_err(&mvotg->pdev->dev, + ret = readl_poll_timeout_atomic(&mvotg->op_regs->usbcmd, tmp, + (tmp & USBCMD_CTRL_RESET), 20, 10000); + if (ret < 0) { + dev_err(&mvotg->pdev->dev, "Wait for RESET completed TIMEOUT\n"); - return -ETIMEDOUT; - } - loops--; - udelay(20); + return ret; } writel(0x0, &mvotg->op_regs->usbintr);