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=-9.7 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,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 771C7C433DF for ; Sun, 5 Jul 2020 06:06:08 +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 4306620771 for ; Sun, 5 Jul 2020 06:06:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="wAo3fLBx"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kGzwoBg+" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4306620771 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=oENuVI75OHJbldQ16xryKWUSO+X6DaA9yIcBAbc0GXw=; b=wAo3fLBxc/Ecl+tG3jDdbWarb1 7a4K1zZep7bC7EEJ0CVeEE/w6J+hYrnQQIHm7VxYghgVw6L4+zhTEhy5UkUuOM7O7fnaPfwvbVth7 O/CKzWfO++aa8sJpKmfsqy2V251W2l/6fH6yDIFesc4Uzlo5WkNgzIZ1RcpsDoGCOGDLm8NQgzT+L R1p5UCclga0OSzzviLiIM4xs/uvPcOuKBhM1wxP9uGJ7E5tXRIuFes5BL8jfKq2MWmy7IgWbu1JOw 5FQbRhsgJWWYSOZlDNKW6W9ncaklBS0v994/jWoyccL6Y3l8dUVnD6WOgJhqR305AXyavNLM882QG l3PcaMXQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrxli-0004K7-Uy; Sun, 05 Jul 2020 06:04:51 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1jrxlg-0004If-Oi for linux-arm-kernel@lists.infradead.org; Sun, 05 Jul 2020 06:04:49 +0000 Received: by mail-pg1-x541.google.com with SMTP id m22so6555422pgv.9 for ; Sat, 04 Jul 2020 23:04:45 -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=vGHyGpCtTzDGX17MIrY06Vl+/0dBVvT7eGpW4IN57jk=; b=kGzwoBg++MIY+bbWpT7gSJyxE+OLmzb5CKa6gwLwDvLcAiUjIH50HUoQKmeem31ThA 48aaIatt5Xlhms2I+eX25j1WpNa++aarPTx94PHMfDzK6k3T15KmD5J9IjtbPDRxtx7l PUcxPYz+jiLZKcjfSuJQPlIR1VOc53ozTRvzPVscq2NEF9S3DVrcZIU2EdXUWJpiRNQ5 7yjcFZucu3fFDvETinWhKizT5p9Pg41eoWhwGtazmNrBvD3yS0eoIrpOVYxnFLfyuku5 3MtA3OmcnB5YfL32WEHo3Ef0JM7LPWWYdGTZkE/WI2+7mWtKzIL7ChfizovIrBV2S9BD VjFw== 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=vGHyGpCtTzDGX17MIrY06Vl+/0dBVvT7eGpW4IN57jk=; b=RhUQOIp7ehJAdPkZvl1aFI6AHtu0PR5CEV/vPM2FZqS/yLjZeLfNF75j/jJ8zy9wu7 vyV3fCZvie3T6F0QWeA82K3YsCFhbCSwSaceM9G47F3S8t0+QiawaCwKfl3IgdaXfwEc vRygoie2S2iJCGmuxJuUiqFLtTS3SV+If688Jr+LmY1fia4VCCCyzKbWYmgxUX2AwdZN S2TUtW0O5/C/lMGmTe27pO4rDfuTgRVmmMh9D3MFbfy+pH9rv9056zi+VwToTX3X4l7/ U8Pqy+tMdtkU4HB95WjuHhYfWmMDePxi4Prq6Vl+yOiwJq4Hxc/SxR8OnG+TiOx9wydh ZKvg== X-Gm-Message-State: AOAM532w/TCLHwYUeBVDrVzIGh1WUliP5y11ruDg0LrnGJpwVNNRpZpW FvDwQzDzi0FQyhe06+CySqch84Yd X-Google-Smtp-Source: ABdhPJwcv1m0vmAxwmfC3m9wLCMV9RDfvvesVYT6bKQk9sF6xz6IXWHFYOIMasWS84Qxe8EyM/3ssQ== X-Received: by 2002:a05:6a00:10:: with SMTP id h16mr37740624pfk.214.1593929083951; Sat, 04 Jul 2020 23:04:43 -0700 (PDT) Received: from localhost.localdomain ([103.51.74.198]) by smtp.gmail.com with ESMTPSA id nh14sm8860676pjb.4.2020.07.04.23.04.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 04 Jul 2020 23:04:42 -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 v2] phy: samsung: Use readl_poll_timeout function Date: Sun, 5 Jul 2020 06:04:35 +0000 Message-Id: <20200705060435.504-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-20200705_020448_910059_52827990 X-CRM114-Status: GOOD ( 13.94 ) 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. Fixes: d8c80bb3b55b ("phy: exynos5-usbdrd: Calibrate LOS levels for exynos5420/5800") Signed-off-by: Anand Moon --- Changes v2: --used the default timeout values. --Added missing Fixed tags. --- 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..c97f5fb6a9a0 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 = 100, sleep_us = 1; 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 = 100; + sleep_us = 1; 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