From patchwork Mon Sep 21 06:13:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?Q2h1bmZlbmcgWXVuICjkupHmmKXls7Ap?= X-Patchwork-Id: 11788331 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 AD05D16BC for ; Mon, 21 Sep 2020 06:17:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 903A2216C4 for ; Mon, 21 Sep 2020 06:17:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="nkPEa13K" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726368AbgIUGRK (ORCPT ); Mon, 21 Sep 2020 02:17:10 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:42163 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726149AbgIUGRI (ORCPT ); Mon, 21 Sep 2020 02:17:08 -0400 X-UUID: 8a75d16a3c1f4e118f9597f83e281977-20200921 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=iytLVyfwsqCD1g9UEuz02b2x3mx6gFmM96o8N8uXFCw=; b=nkPEa13Kx7DLe7rhGyBwYIL4BvhJ7xl68aY7+tcn/gPXaennJShaOnIOaikNLTrQSPieYcyyNEueRQsXicJ4bygdh1UE7WWag/tQyC+ARbfnUKe/IBSnYKnB/gmnDtBD2dJdLNpyBCyELFt3Opstqh41ZvPDaqldsrQwbXSmrog=; X-UUID: 8a75d16a3c1f4e118f9597f83e281977-20200921 Received: from mtkcas36.mediatek.inc [(172.27.4.253)] by mailgw01.mediatek.com (envelope-from ) (mailgw01.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 2038064824; Mon, 21 Sep 2020 14:17:04 +0800 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N2.mediatek.inc (172.27.4.87) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 21 Sep 2020 14:17:04 +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; Mon, 21 Sep 2020 14:17:01 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi CC: Mathias Nyman , Matthias Brugger , Chunfeng Yun , "Eric W. Biederman" , Sumit Garg , Lee Jones , Jann Horn , Jason Yan , Arnd Bergmann , Chuhong Yuan , "Gustavo A. R. Silva" , "Ben Dooks (Codethink)" , Saurav Girepunje , , , , , Sergei Shtylyov , Daniel Thompson Subject: [PATCH v4 05/11] usb: oxu210hp-hcd: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:29 +0800 Message-ID: <1600668815-12135-5-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty In-Reply-To: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> References: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> MIME-Version: 1.0 X-TM-SNTS-SMTP: 980D8799D31CC841754718C45ED7A1AE8DFE241777DE81837D9B0AEB06BE52E02000:8 X-MTK: N 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~v4: 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) */