From patchwork Mon Sep 21 06:13:25 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: 11788369 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 0A17D6CA for ; Mon, 21 Sep 2020 06:25:02 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9BA7120735 for ; Mon, 21 Sep 2020 06:25:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="b7tqyEix"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="ZbFpSqUf" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9BA7120735 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To:From: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References:List-Owner; bh=0O41DQLGC9NtXDkf3IqF9II9jq7IKYD8IiGKGM43Cpk=; b=b7tqyEixVlDf/Dqg96budu/GVC V+6L/uwDvDfhRuM19DVD/N6OHM5Ih5AZWuoBOUXLbVrR6pLXErlgb4Vj5roNXYtfZIg7BD1fOjG4j uh3h+dPQ0O9hVbcTbj4Pk0Guw6H7FekVPECqr34lIb5vTiw39FO8q+MDvdQdiqbjz63sRrjmLNFJV EFJGk+McRtG4x1t8p1r1Bm0WDI+88SR0rx490TGnhvmbV8mpSCMJJB2+FbYZw2WeXa0zoqDoClRV8 mq1nWDs8LI0scN0y4gjEw1zFBZaBayIGCOtHdJSuiapH2AwznJBfX45LHp2R8ylYVIiV2nGc6nH60 D1w4EatQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFFy-0005ZR-Ki; Mon, 21 Sep 2020 06:24:58 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFFg-0005Sd-HU; Mon, 21 Sep 2020 06:24:41 +0000 X-UUID: 1954b4a3ccf2426b83ebc44096fca46c-20200920 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:Message-ID:Date:Subject:CC:To:From; bh=6ZOWN7ki1sN531xAD52X8GiFWf24OghgpbzynrNkwy8=; b=ZbFpSqUfrpltQOQOasvH2BT0nEwirQWUMaZeCkE2hHbhRc1ak1xTCq1696ItuU2e4J4MzGINAlyb4/BU8j8kl9dPF8Jvnx4mD+CkvCR2nbE5g1TDCH+U9ffX1YpxKbCcZYiNvRP4j4cAKJD6U1rR6RhyrqY7KoV4LxlxBe7S9JI=; X-UUID: 1954b4a3ccf2426b83ebc44096fca46c-20200920 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 885030643; Sun, 20 Sep 2020 22:24:38 -0800 Received: from MTKMBS31N1.mediatek.inc (172.27.4.69) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:16:58 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 21 Sep 2020 14:16:56 +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:16:54 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 01/11] usb: early: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:25 +0800 Message-ID: <1600668815-12135-1-git-send-email-chunfeng.yun@mediatek.com> X-Mailer: git-send-email 1.8.1.1.dirty MIME-Version: 1.0 X-TM-SNTS-SMTP: 2F03555C4872A9C51584CA060F9A514A5CB38BC9E5EB911970C0BACFA9D73A672000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_022440_723523_CAB67E01 X-CRM114-Status: GOOD ( 15.07 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Mathias Nyman , Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org, Lu Baolu Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Use readl_poll_timeout_atomic() to simplify code Cc: Lu Baolu Cc: Mathias Nyman Signed-off-by: Chunfeng Yun Reviewed-by: Jann Horn --- v4: add reviewed-by Jann v2~v3: no changes --- drivers/usb/early/xhci-dbc.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/usb/early/xhci-dbc.c b/drivers/usb/early/xhci-dbc.c index c050776..be4ecba 100644 --- a/drivers/usb/early/xhci-dbc.c +++ b/drivers/usb/early/xhci-dbc.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -135,16 +136,9 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done, int wait, int delay) { u32 result; - do { - result = readl(ptr); - result &= mask; - if (result == done) - return 0; - udelay(delay); - wait -= delay; - } while (wait > 0); - - return -ETIMEDOUT; + return readl_poll_timeout_atomic(ptr, result, + ((result & mask) == done), + delay, wait); } static void __init xdbc_bios_handoff(void) From patchwork Mon Sep 21 06:13:26 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: 11788377 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 847D559D for ; Mon, 21 Sep 2020 06:25:34 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 52DD420708 for ; Mon, 21 Sep 2020 06:25:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yCmCd9/s"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="txyqOSAk" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52DD420708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=TDDtMPjKkyhwa71wVSeU/40o91WiULbMovA4Y69ldN8=; b=yCmCd9/sGKiJkQg0k7HqGQHCD dv1GkPaePCYVLL3GO3opdWPoOE6hrGSgn6YrZJeFtV10LH+uRzRO0U1VTuws0/iSOX5lty0Y/deA0 eHambF8JNtyUkkRTJoM7/w0WKbjx4drg33Fiay8ZA/tPVR0XP2J5gmVQhGC3/rS2RR6VdbY+0ll4/ BQFKJpzJtjEoEqtD4RAXLnFV/jVvHntrFxFxM1jEOcKQHApTQf3q6ZI26LuK1MsZPNkX2qyLnW6wO vyZ1a+DaIMRol+3YeZHWrqFcju8jNJBETzWcDT2WSFIR85+6yg4gqG1TvA9Pv1HCXx0gWxU54oAvT 6rDdIp8EQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFGR-0005lD-Eo; Mon, 21 Sep 2020 06:25:27 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFFh-0005Sd-Me; Mon, 21 Sep 2020 06:24:44 +0000 X-UUID: dc9defc220e545658d985ef79d55e87e-20200920 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=Xo5rf9xp9Q898V4NrJeKvL/NbIN1YvfdZlom51aDk10=; b=txyqOSAk8KwtI+KVRkHe9mCLKCDRIvHad4cZtkE9zAvDip3lusVd+Z9ORVI6OtBkUvLULmljoWrrZCj4b3x0QY5DhHR0YMgxx2XhxlLa7FIfpdCxMhRYDLBZmVy7LDEnt9SdzT5P/o36ac8lXimKdtUHWq+yAaMvtZdx/LqQfV0=; X-UUID: dc9defc220e545658d985ef79d55e87e-20200920 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1864512577; Sun, 20 Sep 2020 22:24:38 -0800 Received: from MTKMBS31DR.mediatek.inc (172.27.6.102) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:00 -0700 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; Mon, 21 Sep 2020 14:16:57 +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:16:56 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 02/11] usb: early: ehci-dbgp: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:26 +0800 Message-ID: <1600668815-12135-2-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: 08E2723B77F099582DC762E959887646B7F9FDFF59FD8B41E444D08844B116772000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_022441_956496_00796194 X-CRM114-Status: GOOD ( 14.61 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Petr Mladek , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Use readl_poll_timeout_atomic() to simplify code Cc: "Eric W. Biederman" Cc: Petr Mladek Signed-off-by: Chunfeng Yun --- v2~v4: no changes --- drivers/usb/early/ehci-dbgp.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/drivers/usb/early/ehci-dbgp.c b/drivers/usb/early/ehci-dbgp.c index b075dbf..45b42d8 100644 --- a/drivers/usb/early/ehci-dbgp.c +++ b/drivers/usb/early/ehci-dbgp.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -161,17 +162,11 @@ static inline u32 dbgp_pid_read_update(u32 x, u32 tok) static int dbgp_wait_until_complete(void) { u32 ctrl; - int loop = DBGP_TIMEOUT; - - do { - ctrl = readl(&ehci_debug->control); - /* Stop when the transaction is finished */ - if (ctrl & DBGP_DONE) - break; - udelay(1); - } while (--loop > 0); + int ret; - if (!loop) + ret = readl_poll_timeout_atomic(&ehci_debug->control, ctrl, + (ctrl & DBGP_DONE), 1, DBGP_TIMEOUT); + if (ret) return -DBGP_TIMEOUT; /* From patchwork Mon Sep 21 06:13:27 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: 11788367 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 B8EF16CA for ; Mon, 21 Sep 2020 06:24:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 840E320719 for ; Mon, 21 Sep 2020 06:24:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="s89TXNVX"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="XAa6akjm" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 840E320719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=VmnloXphLq8flVmntwa3K8Eke91TtzEKkkMjGvo2GG0=; b=s89TXNVXlaPpMCW41GfLtmWFO V0Bt+8GPJPIndqdSdACa9hHgzf0BE3+6FAN38u2fMuwcDo1VttljYH0zpHkYTCs1YEDo2ZQX3voj7 jfQzdTOukv+3Wlt6oGmmf5wJsRJ362dlmj786Y/8hpbkCKxkTTciSA0OGNsoY29I+ELVceq4MVSw2 9O6HFHl5UztS6JShgSwmvHUx36p5FTRJ07GELvLKBXYUZZaXhaMJBPcSOlSKGjL80MYTfzb+RScPI XXHim2RQg/KYY9TDkJuBX2l5B8TYHFgd7m2dWbqhxgzBwdIt4OO5AR4OToNAhyFVhE2qpzD8lNTQ1 oPOaQ6XCA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFFx-0005Yu-4e; Mon, 21 Sep 2020 06:24:57 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFFg-0005SM-5D; Mon, 21 Sep 2020 06:24:41 +0000 X-UUID: 5f517061fc164ba1836ef6d2650fb5d8-20200920 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=qI3X9MwE9sMRTnQRdhPZhEZddjHAueHKnEny+Zk541Y=; b=XAa6akjm2f+Sn3BiZvfO/yaEagaIbFCoD2hNlK4uP7iR8uCoo02GxU6iwQVtFjUpfg/G6AB6YYtc1yAMVSk3iGMEIPA9km0uMyaet0q2RXwjI2gIQWBA/fmssqzalAkG4R3tqhtwEJ4MHkeZkU8xo4U1Id8F8OF2c53crhkx0/M=; X-UUID: 5f517061fc164ba1836ef6d2650fb5d8-20200920 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 270014550; Sun, 20 Sep 2020 22:24:38 -0800 Received: from MTKMBS31DR.mediatek.inc (172.27.6.102) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:01 -0700 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; Mon, 21 Sep 2020 14:16:59 +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:16:57 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 03/11] usb: pci-quirks: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:27 +0800 Message-ID: <1600668815-12135-3-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: 421069FA6C9AA675FB54CB2DE9B79D16F9C9FB5D8FC8F7F833225D52AF36DAA72000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_022440_380161_9178AFC6 X-CRM114-Status: GOOD ( 14.17 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Mathias Nyman , Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Use readl_poll_timeout_atomic() to simplify code Cc: Mathias Nyman Signed-off-by: Chunfeng Yun --- v2~v4: no changes --- drivers/usb/host/pci-quirks.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/drivers/usb/host/pci-quirks.c b/drivers/usb/host/pci-quirks.c index b8961c0..8920566 100644 --- a/drivers/usb/host/pci-quirks.c +++ b/drivers/usb/host/pci-quirks.c @@ -16,6 +16,7 @@ #include #include #include +#include #include @@ -1012,15 +1013,9 @@ static int handshake(void __iomem *ptr, u32 mask, u32 done, { u32 result; - do { - result = readl(ptr); - result &= mask; - if (result == done) - return 0; - udelay(delay_usec); - wait_usec -= delay_usec; - } while (wait_usec > 0); - return -ETIMEDOUT; + return readl_poll_timeout_atomic(ptr, result, + ((result & mask) == done), + delay_usec, wait_usec); } /* From patchwork Mon Sep 21 06:13:28 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: 11788341 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 50B186CA for ; Mon, 21 Sep 2020 06:17:26 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1131320719 for ; Mon, 21 Sep 2020 06:17:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="hFamWdGc"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="khZAVi6F" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1131320719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bUh4Qk0j8TI89GAHkMicaGEurGkKl/RMbDhsjtdoSMw=; b=hFamWdGcHaQyA/nh1bAWsKOHZ ESdu8rvUmtQEyoovkqylLFuyPLaDT6ShBOUQ9rxK4DXcRavz8Exxwu/h9dwh3pIRdODBvHaxOwKuU EjDLAei1u3RJdry3cZK+ZhkITTzoMG5DguaI2x8Kdti3MwhAoRwB4CGGcljbEW0LBe6oxDGTIsj93 61f/coAZbrJ6QS8Stcyf8XdNWmjMRQxQnI+o9rRAyqJd0er8+eddxw9ITT0L78ZYelVjnAqV6XGHg PihhxVlbRuKzkR1awXd9qxwD9hjQ8lDCRd+dFz1Ue9xsI75kFU8kaN29JsRoW74YQxMfJ3B+zmbfS PTqkmGJIw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKF8d-0004Yz-SJ; Mon, 21 Sep 2020 06:17:23 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKF8T-0004UQ-07; Mon, 21 Sep 2020 06:17:14 +0000 X-UUID: fe68115c4cf240e1a29d1fd5d199cae1-20200920 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=U22axENSaSmKHtYTwm1iMGOTpOJkveZ+Ct8IXMXHsKI=; b=khZAVi6FzmdPsbkL7v7gMHjuhF++Bo4N5HwGxFQGAsvJCiZJhk/pz2Ad4ogO/WMOTqLxEiuCEYF6AtA2819oVzEGOeg0NfRqsTJ11KzoXrXGcRjsggnxrHXNGBJYVkp4OrNmgsxPJMwTIH5V3JXoqcnJ1s8qCMdwF1j1VMcUUT0=; X-UUID: fe68115c4cf240e1a29d1fd5d199cae1-20200920 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1158002751; Sun, 20 Sep 2020 22:17:05 -0800 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:03 -0700 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:02 +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:16:59 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 04/11] usb: xhci-rcar: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:28 +0800 Message-ID: <1600668815-12135-4-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: F0016E84F75B6688BB13CF221D2E328E07E6887A003D1587A8EF7C2F36539F9F2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_021713_194066_4597D004 X-CRM114-Status: GOOD ( 16.54 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Mathias Nyman , Arnd Bergmann , Mathias Nyman , Jann Horn , Yoshihiro Shimoda , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Use readl_poll_timeout_atomic() to simplify code Cc: Mathias Nyman Cc: Yoshihiro Shimoda Signed-off-by: Chunfeng Yun Reviewed-by: Yoshihiro Shimoda --- v4: changes 1. remove unnecessary parentheses suggested by Yoshihiro 2. fix the wrong return value suggested by Yoshihiro & Daniel v2~v3: no changes --- drivers/usb/host/xhci-rcar.c | 43 ++++++++++++------------------------------- 1 file changed, 12 insertions(+), 31 deletions(-) diff --git a/drivers/usb/host/xhci-rcar.c b/drivers/usb/host/xhci-rcar.c index c1025d3..1bc4fe7 100644 --- a/drivers/usb/host/xhci-rcar.c +++ b/drivers/usb/host/xhci-rcar.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -127,8 +128,7 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd) void __iomem *regs = hcd->regs; struct xhci_plat_priv *priv = hcd_to_xhci_priv(hcd); const struct firmware *fw; - int retval, index, j, time; - int timeout = 10000; + int retval, index, j; u32 data, val, temp; u32 quirks = 0; const struct soc_device_attribute *attr; @@ -166,32 +166,19 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd) temp |= RCAR_USB3_DL_CTRL_FW_SET_DATA0; writel(temp, regs + RCAR_USB3_DL_CTRL); - for (time = 0; time < timeout; time++) { - val = readl(regs + RCAR_USB3_DL_CTRL); - if ((val & RCAR_USB3_DL_CTRL_FW_SET_DATA0) == 0) - break; - udelay(1); - } - if (time == timeout) { - retval = -ETIMEDOUT; + retval = readl_poll_timeout_atomic(regs + RCAR_USB3_DL_CTRL, + val, !(val & RCAR_USB3_DL_CTRL_FW_SET_DATA0), + 1, 10000); + if (retval < 0) break; - } } temp = readl(regs + RCAR_USB3_DL_CTRL); temp &= ~RCAR_USB3_DL_CTRL_ENABLE; writel(temp, regs + RCAR_USB3_DL_CTRL); - for (time = 0; time < timeout; time++) { - val = readl(regs + RCAR_USB3_DL_CTRL); - if (val & RCAR_USB3_DL_CTRL_FW_SUCCESS) { - retval = 0; - break; - } - udelay(1); - } - if (time == timeout) - retval = -ETIMEDOUT; + retval = readl_poll_timeout_atomic((regs + RCAR_USB3_DL_CTRL), + val, val & RCAR_USB3_DL_CTRL_FW_SUCCESS, 1, 10000); release_firmware(fw); @@ -200,18 +187,12 @@ static int xhci_rcar_download_firmware(struct usb_hcd *hcd) static bool xhci_rcar_wait_for_pll_active(struct usb_hcd *hcd) { - int timeout = 1000; + int retval; u32 val, mask = RCAR_USB3_AXH_STA_PLL_ACTIVE_MASK; - while (timeout > 0) { - val = readl(hcd->regs + RCAR_USB3_AXH_STA); - if ((val & mask) == mask) - return true; - udelay(1); - timeout--; - } - - return false; + retval = readl_poll_timeout_atomic(hcd->regs + RCAR_USB3_AXH_STA, + val, (val & mask) == mask, 1, 1000); + return !retval; } /* This function needs to initialize a "phy" of usb before */ 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: 11788333 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 D5F3B17D4 for ; Mon, 21 Sep 2020 06:17:20 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 998AD20719 for ; Mon, 21 Sep 2020 06:17:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qBDnswbo"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="C8qTif4K" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 998AD20719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=qEpqkBF0baA4Llje3+8mDf7rvFtEQk7DEQO0PjB/358=; b=qBDnswbodAfUOWUkgQK01QGSI mwHRYa3cmYkfsvrKjUsjzl1Eb47KOnio4lPjgHl3Zci32cAQgmE9TLOqp1joK37udMTinSgOVf9Pl UuiIujeK6Ocj75dlWHjdHk4NH47kfgmmrpkNMyp1WNNrBo2HrG2qHPTPEEvPuS207/QUeFVg5HeWB Q2S4d1XnvX2L71cmFMXHi5S/dxFr0/nSYAGUKC5Jv4zlsoG17PoYWis06waU46nMqveUS8jrxk9rL 2LfMQCeXZfxch5EkhGwX8Myq6yR/AQLalX+ZX5Ilzt7eCyy3e0aN1c1TdVOo2J1/RguKTrP2xEC4B ASEta9K5A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKF8V-0004We-9T; Mon, 21 Sep 2020 06:17:15 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKF8S-0004UN-VY; Mon, 21 Sep 2020 06:17:14 +0000 X-UUID: 0701e548f922465c84039125ea175ba8-20200920 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=C8qTif4Kk7EtshzWr7JlPVSVkGQsVfvPErZi/oT8egNaaA2nxRXHlbM8K2fO96tIgUVyixmuG4f4pmr7W2Xj1CJiBzzdHvZtV3rusXPIadlWecPAQwRp9eA0VB0LztasC5qyg7r4TyesOna0slrvzFK08Rhp/Mpiae0uONSFZ6w=; X-UUID: 0701e548f922465c84039125ea175ba8-20200920 Received: from mtkcas67.mediatek.inc [(172.29.193.45)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 735701890; Sun, 20 Sep 2020 22:17:05 -0800 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:04 -0700 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 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 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_021713_148756_681FF892 X-CRM114-Status: GOOD ( 16.43 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.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) */ From patchwork Mon Sep 21 06:13:30 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: 11788381 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 8D9316CA for ; Mon, 21 Sep 2020 06:25:41 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 59F6420708 for ; Mon, 21 Sep 2020 06:25:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="G7TrzgEE"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="WYIeaC0j" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 59F6420708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=FEwbVTjlpVJ5ZQbWhPXQ5onBbKOWObmEJ6LIDJKulZc=; b=G7TrzgEE+6sZ0clOkYhm05Xye 05R50lgJSkOg4kywB2oRXrcrplSlYdySmkhg0xwqim0G3JuIY6+S7zcz1WLd9k8iWl1tRAo7EH/i/ nIjw3mOKIKle+cHC9pKMYHSf4sgbwYHlhbUe86qFmw9p0H8RjI1hgvnjsIh938mKVuJrVO0ybkFOa xXPFjQxEzO2JfocOJcbeg5ARohO+ueEr1Tpgzt4WyTeHHbLggVMR4zWM1E8BEgRyX9UsccQJWhg0E c/lSJLzZ65QhpA/0ilQQp4Shw4QaT/LJ8hMa6+iyhtIcRwvW1oeHHzCr9dsfacQJSl6HO5iD5E3OL oMf0Cz24Q==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFGc-0005sT-SR; Mon, 21 Sep 2020 06:25:38 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFFm-0005Sy-Cb; Mon, 21 Sep 2020 06:24:48 +0000 X-UUID: fcc314a79b974ac9a1d954b0546187d5-20200920 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=eXo3ZNdSOv7o75Rg1veepw4qxn8TsYpXE6uoKVo5ls8=; b=WYIeaC0jgLc+2OiqDvNOlgcC+obHfPjp8iHdm/DhvMsjmk5a+XIeaWUi+Dp8aVRBOO//MVstuah1k/PF4D1BhCA2MKakEMHk3YE2sqbOrv0wwS4uAqsBklzeLAj0uIJ0OwbFuclpYmaXEHb/+wsn+mZ9etdSg0OZ2Yptio3JK2c=; X-UUID: fcc314a79b974ac9a1d954b0546187d5-20200920 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1477302311; Sun, 20 Sep 2020 22:24:39 -0800 Received: from MTKMBS31DR.mediatek.inc (172.27.6.102) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:06 -0700 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; Mon, 21 Sep 2020 14:17: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; Mon, 21 Sep 2020 14:17:03 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 06/11] usb: fotg210-hcd: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:30 +0800 Message-ID: <1600668815-12135-6-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: CE95345C94FC4573D10D501B0ECEFF2EE20D259A0C306BD28181E09C342AD6FE2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_022446_613257_E70DC1F0 X-CRM114-Status: GOOD ( 16.36 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v2~v4: no changes --- drivers/usb/host/fotg210-hcd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c index 194df82..1d94fcf 100644 --- a/drivers/usb/host/fotg210-hcd.c +++ b/drivers/usb/host/fotg210-hcd.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -883,18 +884,15 @@ static int handshake(struct fotg210_hcd *fotg210, void __iomem *ptr, u32 mask, u32 done, int usec) { u32 result; + int ret; - do { - result = fotg210_readl(fotg210, 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). From patchwork Mon Sep 21 06:13:31 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: 11788373 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 E84EA59D for ; Mon, 21 Sep 2020 06:25:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id A7A3220719 for ; Mon, 21 Sep 2020 06:25:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="ELQzAPq8"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="rST8D+QC" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org A7A3220719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=g04Vf1zZs8L598d9gWH3h5582qqh/CG1Au5D+UD6OU0=; b=ELQzAPq8ouiUntG5Pqdsq87ux QnpwZRW2MwsBI8X0IF1hNF08Z8DmqZXVgCwj/XHSlSewYnsu2U3+wDpXSHwa2KAfklBx7LtKzUL6f MVdIAC+4yE0/Xyd6D2XmmdfGyWHFw+ROnmNx43BR6Axpril97doRPyQZ0Hx4dH6OQ8Dp1vkrU0rFq I3ywCak2DZbSkB2evmLMDwLrM7BmTVpOBRceUwH3Add8kA9xLSUN5wyKd8JbrIvjAL4h4+tr5Cy8w zqChz22LD3w5BgB1fYhgt3wEcuUSo5bnqPYPhVPCZQrxo4itvbrB+IX4GFr98vBGD2834dB4Q3Unf iX15+2XRA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFGN-0005jh-96; Mon, 21 Sep 2020 06:25:23 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFFi-0005Sy-F6; Mon, 21 Sep 2020 06:24:46 +0000 X-UUID: 49fd69c3b9b644dd99ba935b2df79a99-20200920 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=03QgLwsgOisVZbDGtPu7Lgll5Hbd3GQyWS3uWvzNTQ0=; b=rST8D+QCYmTeL3mwOFI5vJ2LcVgHWjiysvugLZmdWzT8WGVTfcpQePTxFNKu1HMsoJ4qfzb+d/mca0D/KyliYgWsn4m4eIbwUSbXjuDO/dkCjlNaxpA9GCeKhJDyx+qlSGV0rdrOPEcFBEz9mUGAV5zINVZuWNun6WqeEWcwsIs=; X-UUID: 49fd69c3b9b644dd99ba935b2df79a99-20200920 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 689459695; Sun, 20 Sep 2020 22:24:39 -0800 Received: from MTKMBS31DR.mediatek.inc (172.27.6.102) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:07 -0700 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; Mon, 21 Sep 2020 14:17:06 +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:04 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 07/11] usb: isp1760-hcd: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:31 +0800 Message-ID: <1600668815-12135-7-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: 7DBBB53265D7247BC7A4B0C82379CA3038943C4CC4771CF8CE69B2F2BB86AEE32000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_022442_684255_B75D2182 X-CRM114-Status: GOOD ( 15.43 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v2~v4: no changes --- drivers/usb/isp1760/isp1760-hcd.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/drivers/usb/isp1760/isp1760-hcd.c b/drivers/usb/isp1760/isp1760-hcd.c index dd74ab7a..33ae656 100644 --- a/drivers/usb/isp1760/isp1760-hcd.c +++ b/drivers/usb/isp1760/isp1760-hcd.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -380,18 +381,15 @@ static int handshake(struct usb_hcd *hcd, u32 reg, u32 mask, u32 done, int usec) { u32 result; + int ret; + + ret = readl_poll_timeout_atomic(hcd->regs + reg, result, + ((result & mask) == done || + result == U32_MAX), 1, usec); + if (result == U32_MAX) + return -ENODEV; - do { - result = reg_read32(hcd->regs, reg); - if (result == ~0) - return -ENODEV; - result &= mask; - if (result == done) - return 0; - udelay(1); - usec--; - } while (usec > 0); - return -ETIMEDOUT; + return ret; } /* reset a non-running (STS_HALT == 1) controller */ From patchwork Mon Sep 21 06:13:32 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: 11788343 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 8F74259D for ; Mon, 21 Sep 2020 06:17:27 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 344F7212CC for ; Mon, 21 Sep 2020 06:17:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="skOMWcwx"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="JEsyUbsl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 344F7212CC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3M7FEQaoEZDzsLDsBEuawHMRHNhhy2ZKIIW79Vv+0RI=; b=skOMWcwxIYMomrASegcoXMOgj E2+OrDVpEYizKu0zK9BA8g9TgIUIKDyzpXldV+iBK7FQcNNIk9P8v3sOMDgOtMCWoALIxkb0mJ/Xe UCbZlwGTNOQJiYmYTZ1sPr2sJn8+SKvAiLvSZ+ZC2hwloQcUI+Ug8VDrz/wv8iuWsCxZn3GG2N4YT JVN8f3WU8CIZUDDCTLF7mK8/SDpw04YyBZd1mIsO67Z0QOgT0AAYxmTBcqQ1Hepkd54Uw5yi5Xu26 dQrLaRylqkarV2VhYVulvJEkyOiCm76QANfiic+YU+RtBoIBi66cqI64qxlwTc/ZkXNrBHQADizTS ITKtUNXvw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKF8e-0004ZR-SL; Mon, 21 Sep 2020 06:17:24 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKF8W-0004WM-FJ; Mon, 21 Sep 2020 06:17:17 +0000 X-UUID: 74632dd37f4745618212c9f4f06068e8-20200920 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=M+jMphpitAdQKmTgncue8DLUuiChzBueaSc64a9GuJ4=; b=JEsyUbsljaoTfV4vfkOwqthqpXrB98bAWmFUDWhXSd26tt6t9wDwn5NDhb6OS87r4KoPEfb1asWzkq4WJf2AUic/jDgnY7UpFZxw5Xf7WixlnN59C0ZJOS/WU6sjBJhVHbRQBPVNH9ndr7EpxQk8AwJ0e63WWM0l8ckMaFxiLN8=; X-UUID: 74632dd37f4745618212c9f4f06068e8-20200920 Received: from mtkcas68.mediatek.inc [(172.29.94.19)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1723260504; Sun, 20 Sep 2020 22:17:12 -0800 Received: from MTKMBS31DR.mediatek.inc (172.27.6.102) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:10 -0700 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; Mon, 21 Sep 2020 14:17:08 +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:06 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 08/11] usb: phy-ulpi-viewport: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:32 +0800 Message-ID: <1600668815-12135-8-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: EEA5F66F385D1C22FDC9CCE0641F47060E3C27892C8F6ED0949B2FA6AC1DA61E2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_021716_744252_A7C827F1 X-CRM114-Status: GOOD ( 14.06 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v2~v4: no changes --- drivers/usb/phy/phy-ulpi-viewport.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/drivers/usb/phy/phy-ulpi-viewport.c b/drivers/usb/phy/phy-ulpi-viewport.c index 7a14e0e..0f61e32 100644 --- a/drivers/usb/phy/phy-ulpi-viewport.c +++ b/drivers/usb/phy/phy-ulpi-viewport.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -20,16 +21,9 @@ static int ulpi_viewport_wait(void __iomem *view, u32 mask) { - unsigned long usec = 2000; + u32 val; - while (usec--) { - if (!(readl(view) & mask)) - return 0; - - udelay(1); - } - - return -ETIMEDOUT; + return readl_poll_timeout_atomic(view, val, !(val & mask), 1, 2000); } static int ulpi_viewport_read(struct usb_phy *otg, u32 reg) From patchwork Mon Sep 21 06:13:33 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: 11788379 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 A671F6CA for ; Mon, 21 Sep 2020 06:25:37 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 780A920708 for ; Mon, 21 Sep 2020 06:25:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="yvv7yKro"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="hAsT6uFS" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 780A920708 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=3Ge8cXWg17UlfFxp7r2vtibzCtC8bRvXDcR32jExMwQ=; b=yvv7yKro0K3G9mN3vze0a3OBu 71UTQLtncyDlgJcQonfjR/FriddVJDYMYiDhiujX0bR5lZ2JkSB0rNwTYZGfUk6gNCTEWtHxmm3cM i/1oIAIKO2WUkRXHBlza9h/68YWNLP6xfG19ixHFrDvw14E0fy0otp/bNwSc50lji7BZsC1lw13ht VszMCUlR1EOcvsW961sD7b/dc3SxE3uBahEA1492J5hE/8twp3jOmeX830G1f+EsBQIJY6gDEPeUE EflnG1YImDDf3tUvo7AK4rb0cXs7o/9vQslyx1oAJIeUnL25DB/s3Fdb3M6r+fjwzk0vCHzwlNlvW Uxt3g5XjA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFGY-0005or-Qr; Mon, 21 Sep 2020 06:25:34 +0000 Received: from mailgw01.mediatek.com ([216.200.240.184]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFFi-0005Tk-F2; Mon, 21 Sep 2020 06:24:46 +0000 X-UUID: 2b1b23fa444c44f7bebeb518c292825c-20200920 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=fhoC7nd4R36M3issGh+SxVPkb1Qjg4iuhqpKgwaNaKE=; b=hAsT6uFScZzYn1TFbtx1oo5dO16HTZegY8tY2EKHoSPWy6NcBFKqrI3rH5V9f8zbzwwi7bWfO29BeMf3wyCK+JIxAuRdJKSc1gzKNz5JEgIq1JvQDuKPM2eDFDbW3wgKwZgHYv46dED1jYXtePEErZHfhKdlCxukIgN/1O2tbFI=; X-UUID: 2b1b23fa444c44f7bebeb518c292825c-20200920 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw01.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 410405657; Sun, 20 Sep 2020 22:24:39 -0800 Received: from MTKMBS31N1.mediatek.inc (172.27.4.69) by MTKMBS62N2.mediatek.inc (172.29.193.42) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:12 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 21 Sep 2020 14:17:10 +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:08 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 09/11] usb: phy: phy-mv-usb: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:33 +0800 Message-ID: <1600668815-12135-9-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: 2F9FBD9981B001EA895A14F6E8D251A0B594F6BC5073CA2F55F375A17B5E66502000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_022442_684561_95131AEE X-CRM114-Status: GOOD ( 15.93 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Use readl_poll_timeout_atomic() to simplify code Signed-off-by: Chunfeng Yun --- v4: no changes v3: re-align argument of log suggested by Sergei v2: udelay 10us instead of 20us according to kerneldoc --- drivers/usb/phy/phy-mv-usb.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/usb/phy/phy-mv-usb.c b/drivers/usb/phy/phy-mv-usb.c index ce767ec..576d925 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, - "Wait for RESET completed TIMEOUT\n"); - return -ETIMEDOUT; - } - loops--; - udelay(20); + ret = readl_poll_timeout_atomic(&mvotg->op_regs->usbcmd, tmp, + (tmp & USBCMD_CTRL_RESET), 10, 10000); + if (ret < 0) { + dev_err(&mvotg->pdev->dev, + "Wait for RESET completed TIMEOUT\n"); + return ret; } writel(0x0, &mvotg->op_regs->usbintr); From patchwork Mon Sep 21 06:13:34 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: 11788371 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 4E5CB6CA for ; Mon, 21 Sep 2020 06:25:24 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 1D3AD20719 for ; Mon, 21 Sep 2020 06:25:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="SMc6+Oai"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="N/R8B3Pl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1D3AD20719 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=PnEp0Q/r+KQRPht4LXPHcIPup4US23ngoP/7aPDb8cI=; b=SMc6+OaiBq6XC4Y+NHHsAknW5 DL7Qobfo1Vnr5M8m+zSENKQlJ382i+hKx8LBZrVjXWyXZU0UFzhC6DSFKVZk+ums2eu6l5Xxy9kfS tz/XBDuo/jB51H26ro2o7iPHBxs0QnsCVMSfUJH8u7dippU0Tz7TZ4cPFVqB2sMaV2yQRcIeFUrgm 6y2rFCsb5iytlkJCKgIMU/xr73FnOiWKvB0BizpJ7zIbW8Uu+N09N3C5dZ+PGA6gnX4U1FCEqZyyG muMfIvXqMGUBu46Vya5nUwkjWGe9+kzzZLoIaQW3dmFp+5KLl2B8QDw6FlKGQRDRj8sm/fHLh2x3K 2BfYGNyag==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFGK-0005iu-BW; Mon, 21 Sep 2020 06:25:21 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFFh-0005SM-HW; Mon, 21 Sep 2020 06:24:43 +0000 X-UUID: f7a38db68b6e4ab5963202690ae41d3b-20200920 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=oHk1JU2NeVe2tWWWIBxMvDXUuKUJJvTa4oJY401uQng=; b=N/R8B3PlPkmYHq7XnaqxcQwXPAJ8TIcax5q6hoiAB2ve/sVn69TIxtqzjxu6BnJA6c1wopNVnhCW9jvq1kbqYISq5/jqM5YDYoryB0qy/xIeWBCpi9JBGqonxcd0GXvOlHq2L+Lzhjr/YscT1qKRSHF+x1LjOmps3a5J/qwRAwc=; X-UUID: f7a38db68b6e4ab5963202690ae41d3b-20200920 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 462601505; Sun, 20 Sep 2020 22:24:38 -0800 Received: from MTKMBS31N2.mediatek.inc (172.27.4.87) by MTKMBS62DR.mediatek.inc (172.29.94.18) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:14 -0700 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: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; Mon, 21 Sep 2020 14:17:10 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 10/11] usb: udc: net2280: convert to readl_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:34 +0800 Message-ID: <1600668815-12135-10-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: F315BAB8ED3B30B9B6DF2791A863E3E70DFCD786BE5E8679004EC738121DABED2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_022441_747714_5DF6BC80 X-CRM114-Status: GOOD ( 16.00 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Alan Stern , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.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~v4: no changes v2: add Acked-by Alan --- drivers/usb/gadget/udc/net2280.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) 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; From patchwork Mon Sep 21 06:13:35 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: 11788395 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 35F2159D for ; Mon, 21 Sep 2020 06:27:49 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 08A4020739 for ; Mon, 21 Sep 2020 06:27:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="MYdvcAas"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mediatek.com header.i=@mediatek.com header.b="kFugfE6/" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 08A4020739 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=mediatek.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To:Message-ID:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=bvQZBBvI7D1kch1lC98iPFlytUOEGwpwIz/xnRKw0EA=; b=MYdvcAastVV1lzZRFVChrh9pC Wkj43dRLKx7Wx6oW4Z6fvFLNynv7d22ZrmD+wVX7GwbUnw6yiBYl68InQJLe4OfvsaVX2J93ciDB4 GhR/2Mm2lLSw+980zYF6oIWmiekoHQ43VJtRPfmnpxgtYzWjWYUh0689gmihNOrZXw1mhh/miHEYz 9HpNx0H87sKI16EZD5o52c0Nktl/uQx1k+Tu45w0qyLM19TdZsJqesCj6LWywAn2fxkMn3eDvUilp dBxpLQZKEWC+776Ogq1/73dpIaNelEJAJaeL3E/J1Tv4fKON4HxAm2f7NT6kxgk5GpzQWVVY0J7vL UwX+vV76A==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFIf-0006v0-DQ; Mon, 21 Sep 2020 06:27:45 +0000 Received: from mailgw02.mediatek.com ([216.200.240.185]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kKFII-0006k5-6q; Mon, 21 Sep 2020 06:27:25 +0000 X-UUID: 8b414f7add824781a483b3a184751eb7-20200920 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=6qZ3MFCp67LQIehQWoxsg/JhWq3n6ohpU0YiOM2IRh4=; b=kFugfE6/qY/8hN5o7jUXFGnZvghMKfSnBZQxTcebq66WqU0/2W/NR0EBz23/RY3TfDgjhjGPW7LE5eWOSgXDzNFWMJeLUzboCYfjwWDpYTyxoOaPuDbj9TPTDGfoe6bP3VFjm7B9hXEUOLtT+rGXzMWw/NSY7kl0pNKhvfZl5E8=; X-UUID: 8b414f7add824781a483b3a184751eb7-20200920 Received: from mtkcas66.mediatek.inc [(172.29.193.44)] by mailgw02.mediatek.com (envelope-from ) (musrelay.mediatek.com ESMTP with TLSv1.2 ECDHE-RSA-AES256-SHA384 256/256) with ESMTP id 1612736876; Sun, 20 Sep 2020 22:27:18 -0800 Received: from MTKMBS31N1.mediatek.inc (172.27.4.69) by MTKMBS62N1.mediatek.inc (172.29.193.41) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Sun, 20 Sep 2020 23:17:15 -0700 Received: from MTKCAS06.mediatek.inc (172.21.101.30) by MTKMBS31N1.mediatek.inc (172.27.4.69) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Mon, 21 Sep 2020 14:17:14 +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:12 +0800 From: Chunfeng Yun To: Greg Kroah-Hartman , Felipe Balbi Subject: [PATCH v4 11/11] iopoll: update kerneldoc of read_poll_timeout_atomic() Date: Mon, 21 Sep 2020 14:13:35 +0800 Message-ID: <1600668815-12135-11-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: 12B795415FC0ED3118BA475BA2E81ADE4E49B603F95922E5AACB3B2F03B46E0A2000:8 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200921_022722_453741_7906B625 X-CRM114-Status: GOOD ( 15.08 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.0 MIME_BASE64_TEXT RAW: Message text disguised using base64 encoding -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid 0.0 UNPARSEABLE_RELAY Informational: message has unparseable relay lines X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sumit Garg , Daniel Thompson , linux-usb@vger.kernel.org, Arnd Bergmann , Mathias Nyman , Jann Horn , Jason Yan , Chuhong Yuan , "Gustavo A. R. Silva" , linux-kernel@vger.kernel.org, Saurav Girepunje , Chunfeng Yun , "Ben Dooks \(Codethink\)" , linux-mediatek@lists.infradead.org, "Eric W. Biederman" , Matthias Brugger , Alan Stern , Lee Jones , Sergei Shtylyov , linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org Arguments description of read_poll_timeout_atomic() is out of date, update it. Cc: Alan Stern Signed-off-by: Chunfeng Yun --- v4: no changes v3: fix typo in commit message suggested by Sergei v2: new patch, suggested by Alan --- include/linux/iopoll.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/iopoll.h b/include/linux/iopoll.h index bc89ac6..2c8860e 100644 --- a/include/linux/iopoll.h +++ b/include/linux/iopoll.h @@ -60,8 +60,7 @@ /** * read_poll_timeout_atomic - Periodically poll an address until a condition is * met or a timeout occurs - * @op: accessor function (takes @addr as its only argument) - * @addr: Address to poll + * @op: accessor function (takes @args as its arguments) * @val: Variable to read the value into * @cond: Break condition (usually involving @val) * @delay_us: Time to udelay between reads in us (0 tight-loops). Should @@ -69,6 +68,7 @@ * Documentation/timers/timers-howto.rst). * @timeout_us: Timeout in us, 0 means never timeout * @delay_before_read: if it is true, delay @delay_us before read. + * @args: arguments for @op poll * * Returns 0 on success and -ETIMEDOUT upon a timeout. In either * case, the last read value at @args is stored in @val.