Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp8841620ybi; Thu, 6 Jun 2019 21:50:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxk3+ByvME1PWkhQbLg+P7Ex/JZcAwIa6G+Dqo7aiSnJg0GksL3PUH/9zICSWD+CBXfGc0H X-Received: by 2002:a17:90a:26ef:: with SMTP id m102mr3408487pje.50.1559883012325; Thu, 06 Jun 2019 21:50:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559883012; cv=none; d=google.com; s=arc-20160816; b=mqSddmy8Vi9yfBwFnf7EhDcKM0NKg3j/u7RjITyTDxNGnD/E7KzI/vpDXcH/vRX01i 5xhhZo/WsZhDaWMste9y3QeAbRX3zWpL0PnHCghjJQCZBFGFc0w1B0n50PLFGLTdzdG7 tzpPagULNIf3bR1nY0xNrrnYfrlChAEvrSV+FLKA7qJYh1LtQDE+iMfgNK79+AZ5Xprx OSJWUG46NVAXDO0IZLDyuVmTRy0Rn3HVRN6sbO19GMGQtDhAHArm04gwbytl5Zw3kxIx 4Lqf3/cAxvo82TCwfI14D6yYK/MhsHcfBXj2OVych5/GVeoKbc7c3Gln6As8NvNLA03s 65kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3eDYtx1SaX5ezeZL1yvMz2TA5bp73da63R7mtvE27ww=; b=DZm340SJrH6WMWNlT66/6QKzqMr7rrPO09dp1CyCCzHQQCLUU5IEJV4EIgT0JbYmHU MB2em5CQzrpXp3M1ewi+rP4llmJDK/jVwKDVrqTg13OE/59NA/cqj1l6Wt37gahZH4X/ EZGYXH9xtEjJCPWbIDt+idikmVSETRR3q/GPBibJpPQSuCatdqvM684RMu65eN2cE5k0 0wzjGu/mqZXOXIZGrhLUl0/5DbdCQLxBU+F8Aa072JeDClz6wFNO+sY8GdrRdAHLu4YC BEz/OVtna+7jdIZrS1hYmiO0PlsO0/M4/PlqSjjkXIi/M29Vl3r6i37zkbcYvM2kArQL 4sSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NbXke3b2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q17si971907pgl.27.2019.06.06.21.49.56; Thu, 06 Jun 2019 21:50:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NbXke3b2; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726023AbfFGEq2 (ORCPT + 99 others); Fri, 7 Jun 2019 00:46:28 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:42967 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbfFGEq2 (ORCPT ); Fri, 7 Jun 2019 00:46:28 -0400 Received: by mail-pg1-f193.google.com with SMTP id e6so473096pgd.9 for ; Thu, 06 Jun 2019 21:46:27 -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:in-reply-to:references :mime-version:content-transfer-encoding; bh=3eDYtx1SaX5ezeZL1yvMz2TA5bp73da63R7mtvE27ww=; b=NbXke3b2qlDIEr+OgQCHGhnfYfyjuzBOi6Vmzc5+N4u29mWad7c/5SHCexsVl7NS2o 4AZjKAuB5MYldANKtxvXX0lFzwDKQokVj1+RDxXXJEfm+fWjTAKT8lYCT4FdDq8rmuz9 2KAUECG3ExiflZfBRN4PI25kaPLqE/oyG0dA3CFcAKvzoOigS2zbgpoBPrFEbA/lvPIo pB0JbZjLaFtQOXPqdnUnvioHkjKMsoNrxqNaAfUhblKMQrksKByyMBvUnh+Ue7BF6up6 8LvVFCB31XzcRzqpWWCOZvbhFdqks4VGrYoktF0unxDIEbt69s2K67FwN6JWjBR1ytX0 /Wog== 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=eVPQ3FRXlMoGoBanbUu/wXEwwEvzqGwW8KN8YVo2grUwMvKUmFHHrlalzEBWqp6x8O hqqIswJTvOkrIMMEyFeiB/7KELIGTXR5Iege5aLClP9ojKLniJMzjhzukwYfX/aBFzDl XJeXm1GMHPfkJkTOXcIlu7u0fixV/IKekbCp98rYSoMtvi/kHSIvahc8xfpuSSMUZdEy FfEpdz4hDGACNBHrVk0AUwY1twn+mBXAGcQiOnboAuN4T8f9BRR66bpeJk6AGzlEAYcq NGSP7fcIkDdzs1Mp+jh3tslOjHX6YPt10IM3GPD4Jv2M849m/7AKYkzwnrb6LxLoHuqF YGnQ== X-Gm-Message-State: APjAAAXWaMRCPPXT60FdGOrcK0seWSi5Z+ef6UhMp/oRPvBAsd1f9+u3 6zoPcgu9brQGDas6v4z0OBk= X-Received: by 2002:a63:7e43:: with SMTP id o3mr1139642pgn.450.1559882787321; Thu, 06 Jun 2019 21:46:27 -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 o13sm919516pfh.23.2019.06.06.21.46.25 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 06 Jun 2019 21:46:26 -0700 (PDT) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Cc: Andrey Smirnov , Andrzej Hajda , Laurent Pinchart , Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Cory Tusar , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v4 01/15] drm/bridge: tc358767: Simplify tc_poll_timeout() Date: Thu, 6 Jun 2019 21:45:36 -0700 Message-Id: <20190607044550.13361-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190607044550.13361-1-andrew.smirnov@gmail.com> References: <20190607044550.13361-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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; -- 2.21.0