From patchwork Wed Jun 12 08:32:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10991315 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8BFA7924 for ; Thu, 13 Jun 2019 07:30:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 789DD28707 for ; Thu, 13 Jun 2019 07:30:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C4E1287B7; Thu, 13 Jun 2019 07:30:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0822228707 for ; Thu, 13 Jun 2019 07:30:41 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A309489491; Thu, 13 Jun 2019 07:28:19 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by gabe.freedesktop.org (Postfix) with ESMTPS id B3645892D8 for ; Wed, 12 Jun 2019 08:33:06 +0000 (UTC) Received: by mail-pf1-x441.google.com with SMTP id j2so9221289pfe.6 for ; Wed, 12 Jun 2019 01:33:06 -0700 (PDT) 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=3eDYtx1SaX5ezeZL1yvMz2TA5bp73da63R7mtvE27ww=; b=fRTLhYG922rfJPNzjD2bGk1a2yyYPBuoGW+w8ZJvBM4CzOE0UaiCMm+qmn7YjzFSTL 4jUAKPyasDacZnslOCmOdo0M/1SIpeiq/nD16vct66oXWFL0t+COD+h6/bdDVsnW8/VP Puag3edj1xtkg+vSRBYrrv67XGCUMJRWdmsbhguKQ1t0FLZaeARDyaeVYNCX6N41Fu6t ZZTKpigqF2tHjxPqBa1C59YCmi+nsJfnQ5snGMfy9Ama314FI5Tj8uPq0qh8JAET5TnZ mgLU0MJ2eMTTIJAg5MII1xGUpUPvIfDz/53jQdMYh3CmYObdTt/lird/Zm+UXbnD5EtK vK0A== X-Gm-Message-State: APjAAAWpb8iRe5yVMIihX5glYCEDhzY4RnTLYMJseKBqhzTfY3npgtra 24HTHVsRSuXUmTGpRv+FUrLDPflSJho= X-Google-Smtp-Source: APXvYqylQdbs0qQNgPb6HfID161kQnJwYcxMWF/6k7/7L7g/NgRCf/rN0DEA4HcGT3+xR/9GdiUM+w== X-Received: by 2002:a17:90a:ad41:: with SMTP id w1mr31232310pjv.52.1560328385785; Wed, 12 Jun 2019 01:33:05 -0700 (PDT) Received: from localhost.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id d21sm18845991pfr.162.2019.06.12.01.33.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 01:33:05 -0700 (PDT) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH v5 01/15] drm/bridge: tc358767: Simplify tc_poll_timeout() Date: Wed, 12 Jun 2019 01:32:38 -0700 Message-Id: <20190612083252.15321-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190612083252.15321-1-andrew.smirnov@gmail.com> References: <20190612083252.15321-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 13 Jun 2019 07:27:23 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3eDYtx1SaX5ezeZL1yvMz2TA5bp73da63R7mtvE27ww=; b=Qk1R7MqZa9Gr9tjkCwl11RalVFSB915VNouBPrvwfBO9lorQBbp7X8Jyd7aga+98Rl FihMvVAZ8/EgFppumiMRcEQOdszZMnsM7re1t8uMnibI8np0u0Ydu8U74WWnwVUT7wXN AqVAf+cQdLwcy3UGMuga4TH5Fx3iWaA3KOKXPtlAYTdH1ng3iI+hAdHIEFotqb76HTJg yHnaoqMiTpAEpvppbim/2mKz8Xss5BrdGX8y74VPTi26CkqWljTS8aCH+Jul13rGjLd3 zP+W3p5eMiEMWjqVbyfmLzQmVd6cVYHQAUmkpSYxS2QiU18Hxy6bzHflTAibffmeJ/BW lt9g== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Cory Tusar , Andrey Smirnov , Andrey Gusakov , linux-kernel@vger.kernel.org, Tomi Valkeinen , Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Implementation of tc_poll_timeout() is almost a 100% copy-and-paste of the code for regmap_read_poll_timeout(). Replace copied code with a call to the original. While at it change tc_poll_timeout to accept "struct tc_data *" instead of "struct regmap *" for brevity. No functional change intended. Signed-off-by: Andrey Smirnov Reviewed-by: Andrzej Hajda Reviewed-by: Laurent Pinchart Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Tomi Valkeinen Cc: Andrey Gusakov Cc: Philipp Zabel Cc: Cory Tusar Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 58e3ca0e25af..fb8a1942ec54 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -264,34 +264,21 @@ static inline struct tc_data *connector_to_tc(struct drm_connector *c) goto err; \ } while (0) -static inline int tc_poll_timeout(struct regmap *map, unsigned int addr, +static inline int tc_poll_timeout(struct tc_data *tc, unsigned int addr, unsigned int cond_mask, unsigned int cond_value, unsigned long sleep_us, u64 timeout_us) { - ktime_t timeout = ktime_add_us(ktime_get(), timeout_us); unsigned int val; - int ret; - for (;;) { - ret = regmap_read(map, addr, &val); - if (ret) - break; - if ((val & cond_mask) == cond_value) - break; - if (timeout_us && ktime_compare(ktime_get(), timeout) > 0) { - ret = regmap_read(map, addr, &val); - break; - } - if (sleep_us) - usleep_range((sleep_us >> 2) + 1, sleep_us); - } - return ret ?: (((val & cond_mask) == cond_value) ? 0 : -ETIMEDOUT); + return regmap_read_poll_timeout(tc->regmap, addr, val, + (val & cond_mask) == cond_value, + sleep_us, timeout_us); } static int tc_aux_wait_busy(struct tc_data *tc, unsigned int timeout_ms) { - return tc_poll_timeout(tc->regmap, DP0_AUXSTATUS, AUX_BUSY, 0, + return tc_poll_timeout(tc, DP0_AUXSTATUS, AUX_BUSY, 0, 1000, 1000 * timeout_ms); } @@ -598,8 +585,7 @@ static int tc_aux_link_setup(struct tc_data *tc) tc_write(DP1_PLLCTRL, PLLUPDATE | PLLEN); tc_wait_pll_lock(tc); - ret = tc_poll_timeout(tc->regmap, DP_PHY_CTRL, PHY_RDY, PHY_RDY, 1, - 1000); + ret = tc_poll_timeout(tc, DP_PHY_CTRL, PHY_RDY, PHY_RDY, 1, 1000); if (ret == -ETIMEDOUT) { dev_err(tc->dev, "Timeout waiting for PHY to become ready"); return ret;