From mboxrd@z Thu Jan 1 00:00:00 1970 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=-10.0 required=3.0 tests=DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 67D3EC433E0 for ; Fri, 3 Jul 2020 13:21: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 3516B20760 for ; Fri, 3 Jul 2020 13:21: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="YF4yX2w3"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KBO1XJ5z" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3516B20760 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.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=Ec/ItVHbNKVuule+sYQbRWRq5yJKCJJLKW4REqi74Dc=; b=YF4yX2w3scTeruZZfwvFVu6DGn 2YAYccknYxwidZ6iLAVQy+hYC0XGJQ1MRfXddJSz3HEmSjb1lxxZmS+sPvsJJ2+7Vq+bXY76hSiFF mxrgdUWaBKB+NqVcQU4sL9uzhaTt6wkEdzjNQ88O3BWOKXO/gQsla9Tf7nh5PFEnfAmTup+YWvPX7 hwdOze31tLKEuDb3lWTS2jbciVjPKZKXS2623NHbLX9PKcrmuQ1GzaptelI0UuxO/JcAKOnY8H7Jk KFL98BYDokRkqwodUy8sH0TupsRF2NahpEXBxJIWNdjUwYjvXPg5+jQ3cMrg2jQnOkPlNvlKWZtlk v+TnBbIA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrLcB-0001dl-DM; Fri, 03 Jul 2020 13:20:27 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrLc8-0001d4-SY for linux-arm-kernel@lists.infradead.org; Fri, 03 Jul 2020 13:20:25 +0000 Received: by mail-pf1-x444.google.com with SMTP id x3so8452416pfo.9 for ; Fri, 03 Jul 2020 06:20:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LDiFULixaebs2MrsIr7/asrSZO8qQssL9OgufzsRRnY=; b=KBO1XJ5zAIjPFUjuxrpGgKmLwz0mXFjXa559w/Dgr+rBE+hEw+sVLFas/aRJSVyQIX cPfYRDxpl97pxvktYM6nSWFJZsN9ky9lLF+m4shdFGtqKIEmvxOYlPxIcJTvEqrtMAMz dNrqX53T8KnWVVRCtTOs4bmOXUWuVditN/vPtyWVv766Y80sQ1mBJRXmfIDrb4I8vsI+ 5Tj5jVn+UeU7Ksv9r780PQNE0FAJ9ixBdCcM7ZnM+nb4Xxir/v56dwD/yS+/hZ6fN0QG 2twPoKWn+cZNfm//ONxJUMVQNpEny3oJm3NSEiAtI7JnE4XGo9IfxelfiWwrc3FoHS0u y4UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LDiFULixaebs2MrsIr7/asrSZO8qQssL9OgufzsRRnY=; b=mfuW7fItIouc8EXUkOweKA+A0rdz8cb6egY7QJtA8c7ZzNeL5Tv+QQLqKefnGD1say PVwY8kj0NVSQuAiKlGfQ13RBDW9JqjDVpXF93F4UGO/6Jmth/I95Be2n+eW11Inj8GcJ eK/E8h+K+sd8Bz/gkiIzAm/UL8ivfHcjKEC76ugo/3j4HBFTv3arObj5TAaNPG+SaTHv bapbJwFxfKytmlbW5/hdK6AdYMM/OKPiHxbegRzZXy8KZORN9YupCQBbMY4tD0NzoeJ6 YOl8uXRm2xLy1nDrHrAJBjrkpLlJkzLmkSyUxDfs+Q755G4XamP3AqcWZdKO5ljOsdD+ BRqQ== X-Gm-Message-State: AOAM532+t14MfVJksiCAURO3KiVMgGJDCSoAU+Hvo5zYljrKffPCxIZw Z9ShGnbCc5fBdq9OVj+zK/SL1HtK X-Google-Smtp-Source: ABdhPJzurlv8AWULBx68fy6iuWnB779WRjX6EPfzmLgBnv+o31xLSHolYNxGWmjnGyerIGkgX1Nfzg== X-Received: by 2002:a62:8782:: with SMTP id i124mr32943371pfe.267.1593782420821; Fri, 03 Jul 2020 06:20:20 -0700 (PDT) Received: from localhost.localdomain ([103.51.74.198]) by smtp.gmail.com with ESMTPSA id q10sm12706937pfk.86.2020.07.03.06.20.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jul 2020 06:20:19 -0700 (PDT) From: Anand Moon To: linux-arm-kernel@lists.infradead.org, linux-samsung-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] phy: samsung: Use readl_poll_timeout function Date: Fri, 3 Jul 2020 13:20:12 +0000 Message-Id: <20200703132012.579-1-linux.amoon@gmail.com> X-Mailer: git-send-email 2.27.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200703_092024_967601_321F1B2F X-CRM114-Status: GOOD ( 13.87 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marek Szyprowski , Vinod Koul , Kukjin Kim , Krzysztof Kozlowski , Kishon Vijay Abraham I Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org User readl_poll_timeout function instead of open coded handling in crport_handshake function. Signed-off-by: Anand Moon --- drivers/phy/samsung/phy-exynos5-usbdrd.c | 37 +++++++++--------------- 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/drivers/phy/samsung/phy-exynos5-usbdrd.c b/drivers/phy/samsung/phy-exynos5-usbdrd.c index e510732afb8b..83274c5e3820 100644 --- a/drivers/phy/samsung/phy-exynos5-usbdrd.c +++ b/drivers/phy/samsung/phy-exynos5-usbdrd.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -556,40 +557,28 @@ static int exynos5_usbdrd_phy_power_off(struct phy *phy) static int crport_handshake(struct exynos5_usbdrd_phy *phy_drd, u32 val, u32 cmd) { - u32 usec = 100; + u32 timeout_us = 1000, sleep_us = 10; unsigned int result; + int err; writel(val | cmd, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); - do { - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1); - if (result & PHYREG1_CR_ACK) - break; - - udelay(1); - } while (usec-- > 0); - - if (!usec) { - dev_err(phy_drd->dev, - "CRPORT handshake timeout1 (0x%08x)\n", val); + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, + result, (result & PHYREG1_CR_ACK), sleep_us, timeout_us); + if (err) { + dev_err(phy_drd->dev, "CRPORT handshake timeout1 (0x%08x)\n", val); return -ETIME; } - usec = 100; + timeout_us = 1000; + sleep_us = 10; writel(val, phy_drd->reg_phy + EXYNOS5_DRD_PHYREG0); - do { - result = readl(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1); - if (!(result & PHYREG1_CR_ACK)) - break; - - udelay(1); - } while (usec-- > 0); - - if (!usec) { - dev_err(phy_drd->dev, - "CRPORT handshake timeout2 (0x%08x)\n", val); + err = readl_poll_timeout(phy_drd->reg_phy + EXYNOS5_DRD_PHYREG1, + result, !(result & PHYREG1_CR_ACK), sleep_us, timeout_us); + if (err) { + dev_err(phy_drd->dev, "CRPORT handshake timeout2 (0x%08x)\n", val); return -ETIME; } -- 2.27.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel