From patchwork Tue Feb 26 19:36:05 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10831429 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 85FEC1390 for ; Wed, 27 Feb 2019 08:56:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 71EAD2B002 for ; Wed, 27 Feb 2019 08:56:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6657A2C162; Wed, 27 Feb 2019 08:56:44 +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 1EF5F2B002 for ; Wed, 27 Feb 2019 08:56:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E8C976E03B; Wed, 27 Feb 2019 08:56:30 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by gabe.freedesktop.org (Postfix) with ESMTPS id 68CD06E020 for ; Tue, 26 Feb 2019 19:36:34 +0000 (UTC) Received: by mail-pg1-x543.google.com with SMTP id q206so6687250pgq.4 for ; Tue, 26 Feb 2019 11:36:34 -0800 (PST) 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=ZD8IznxWy7CqeE4Azr2UQLZvJTlUTz8IeNFsGWvGXF8=; b=uQ+hf2lsyTmqOKjJL66E6pqG/qWinNXCmUHa09MzA+Yqf/IUveo0U6NF4KqH/SElpP O8P0zRAmm9BEzuxCwP95dofRFz611dKcyFJ3a6cXK5Fuq4Ulq39aY0HxXHkMJmHdHkGX Qe7tfWUhQpdbiJQJfWuYz3+s7aCbFDXyLzKvdoBkJct50IROhxQTZNiOvHUhno7u8THc kzVHoOgVWqiZHebvnUDWA13QZq+q3MHhw15HY6gJycwkyOsSsA7dlB9ZrFrMAWZRfDNx w22G6S2o/ky7XinnSFy5B5kzlm2eeD1k1/iJc+yTC3c+VpRiUaegTOV7MDKV6N+wiGbQ GNZw== X-Gm-Message-State: AHQUAuZD1yjyfJykhV2oQG+0AW+YQ5IEE/LtshBFYLPrEoHOzFwZ6j/f qvz1eWXMEf3Mp2Loy45gKdeJE9M4chA= X-Google-Smtp-Source: AHgI3IbXRwVqDQxRzoxQGu32bhQ3aNhR3RbMzJH7j0vuVh6N/rMuNaUuRED/IT6Ld/RAlD50PH+xFA== X-Received: by 2002:a63:295:: with SMTP id 143mr25173772pgc.362.1551209793568; Tue, 26 Feb 2019 11:36:33 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id l79sm28951220pfb.102.2019.02.26.11.36.32 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 26 Feb 2019 11:36:32 -0800 (PST) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Subject: [PATCH 5/9] drm/bridge: tc358767: Simplify polling in tc_link_training() Date: Tue, 26 Feb 2019 11:36:05 -0800 Message-Id: <20190226193609.9862-6-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190226193609.9862-1-andrew.smirnov@gmail.com> References: <20190226193609.9862-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 27 Feb 2019 08:56:29 +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=ZD8IznxWy7CqeE4Azr2UQLZvJTlUTz8IeNFsGWvGXF8=; b=LV03iVYNnCMB0G8raqGDzG20KEeQp3RHnwMz2e39Efl7rwsHJC3PGJxRVdtdUuTaRL ATxr/pcl9WPt4QL0WuqecylqPAjq5Uuk6NK0qk7heD7D3I0TskQokT8eWyG+Mt+4N2vr MagL11g9Fx1t1X1jh2z1svXL7ulX3+7uMyNAgCrSH2AtBRbG49xnvO8YRNw9gUhwYz4a E5XE7oDlwAgUPd78/3HAbFiJirTh5YpygzhE9akTutFBfe7dc5purIYEd3w7g6fM1SVk ukI7+kH43p499Q3gwCqFolrCfaAc2Zw8dTrJBzhfLG/XDtymHmCwWYLFZ0pLqzK5NyJu kGrw== 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: Andrey Smirnov , linux-kernel@vger.kernel.org, Laurent Pinchart , Chris Healy Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Replace explicit polling in tc_link_training() with equivalent call to regmap_read_poll_timeout() for simplicity. No functional change intended (not including slightly altered debug output). Signed-off-by: Andrey Smirnov Cc: Archit Taneja Cc: Andrzej Hajda Cc: Laurent Pinchart Cc: Chris Healy Cc: Lucas Stach Cc: dri-devel@lists.freedesktop.org Cc: linux-kernel@vger.kernel.org --- drivers/gpu/drm/bridge/tc358767.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/bridge/tc358767.c b/drivers/gpu/drm/bridge/tc358767.c index 6455e6484722..ea30cec4a0c3 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -735,7 +735,6 @@ static int tc_link_training(struct tc_data *tc, int pattern) const char * const *errors; u32 srcctrl = tc_srcctrl(tc) | DP0_SRCCTRL_SCRMBLDIS | DP0_SRCCTRL_AUTOCORRECT; - int timeout; int retry; u32 value; int ret; @@ -765,20 +764,17 @@ static int tc_link_training(struct tc_data *tc, int pattern) tc_write(DP0CTL, DP_EN); /* wait */ - timeout = 1000; - do { - tc_read(DP0_LTSTAT, &value); - udelay(1); - } while ((!(value & LT_LOOPDONE)) && (--timeout)); - if (timeout == 0) { + ret = regmap_read_poll_timeout(tc->regmap, DP0_LTSTAT, value, + value & LT_LOOPDONE, 1, 1000); + if (ret) { dev_err(tc->dev, "Link training timeout!\n"); } else { int pattern = (value >> 11) & 0x3; int error = (value >> 8) & 0x7; dev_dbg(tc->dev, - "Link training phase %d done after %d uS: %s\n", - pattern, 1000 - timeout, errors[error]); + "Link training phase %d done: %s\n", + pattern, errors[error]); if (pattern == DP_TRAINING_PATTERN_1 && error == 0) break; if (pattern == DP_TRAINING_PATTERN_2) {