From patchwork Thu Sep 10 08:21:51 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: 297672 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,URIBL_BLOCKED,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 1FDA5C433E2 for ; Thu, 10 Sep 2020 08:26:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE21F2076D for ; Thu, 10 Sep 2020 08:26:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="n1F+Z4OM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729691AbgIJIZs (ORCPT ); Thu, 10 Sep 2020 04:25:48 -0400 Received: from Mailgw01.mediatek.com ([1.203.163.78]:34841 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1729988AbgIJIYh (ORCPT ); Thu, 10 Sep 2020 04:24:37 -0400 X-UUID: 4f4507b6949c4952b75b4b6bf8bb933a-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=LsbK3aFahnUwEjBrSyDBs20PI2uINsZC3CgcxYtUvus=; b=n1F+Z4OMPrzN1crhvk9ajNgkr92aVqNjMuL9h3HkEJV6+wypgq37vTFB3ppEZrsQaB+YdiC3kG9Nj+9h2txC4dxIel8yBDnb81mZcMc1DIM2uADk/lixSO8zTvR6Gwibx+Fhg2JWVuIbC8SaBTJICZP2OJ7E2zScoFQ2APIlWdE=; X-UUID: 4f4507b6949c4952b75b4b6bf8bb933a-20200910 Received: from mtkcas35.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 1473391881; Thu, 10 Sep 2020 16:24:14 +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:13 +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:12 +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 , , , , , Alan Stern Subject: [PATCH RESEND v3 10/11] usb: udc: net2280: convert to readl_poll_timeout_atomic() Date: Thu, 10 Sep 2020 16:21:51 +0800 Message-ID: <1599726112-4439-10-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: BE6E2F2B92070E6D9ADDB1909749E3B84BAB997B565150EDC2B09943C0C282692000: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 Cc: Alan Stern Cc: Felipe Balbi Signed-off-by: Chunfeng Yun Acked-by: Alan Stern --- v3: no changes v2: add Acked-by Alan --- drivers/usb/gadget/udc/net2280.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) -- 1.9.1 diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 7530bd9..f1a21f4 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -52,6 +52,7 @@ #include #include #include +#include #include #include @@ -360,18 +361,16 @@ static inline void enable_pciirqenb(struct net2280_ep *ep) static int handshake(u32 __iomem *ptr, u32 mask, u32 done, int usec) { u32 result; + int ret; - do { - result = readl(ptr); - if (result == ~(u32)0) /* "device unplugged" */ - 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) /* device unplugged */ + return -ENODEV; + + return ret; } static const struct usb_ep_ops net2280_ep_ops;