Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp5408857ybi; Wed, 12 Jun 2019 01:57:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWRghukN4nfv5BOnDAHtIOeyto8Uge02z/eWeg+Q3D74C10q177iLW2ZM7mUNFxo7RMr0x X-Received: by 2002:a17:90a:7f91:: with SMTP id m17mr31759595pjl.86.1560329842124; Wed, 12 Jun 2019 01:57:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560329842; cv=none; d=google.com; s=arc-20160816; b=m77XojrBVjefBslfyziwHvSqWCGojlgzK920AnPIsIU0ZwGPZ1hCeWojoLPMnmFAZq 4vriA9r46fy+O263i3UXkEn5ix4o49CC7XrgbGl5zKSQGiYGIi2Mr9DWYw3izKE2QLWB aueVzm8t8Ls5ocLVEk01vq3GAaL0WjNreM8HaXjrC6h3E6GgXrPd0IFBmBx0JTE33YgG 8/v/cAWJgmDxsraBj4rfsbqN32swQYZBVMVFWRj/4Q4KZQyTYcUAtRwaa/nh/jDqM0Xj iw9qaizZEPkx8WoFKRCYKLUSEXravTYVyHWdlfCp29Adbi50jAJTjSuZtQiBcPb4xGgT Zryw== 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=vTazkThR1hz0kAJgMliIJgyO8P+APIgxqNPsqTckn7zTBk2wAonq10IhNwbVC4JG0N VRxQv47GLlxX6wJDsNXP1ze8mmX7QFoM40Jl2L65BuRMirznB0bz/JMzcMUqb7aaGDYK nCFh86S5wp7CaeF/9JpNKA2cqSfHKwY0h6RxBXhiJGd7v3S7ubqHaPzJXRR0uviyEu+2 4dxHuj5Vb2wjz6h2/uYZnJdq/+BCWNaMAwoqniVC6keYW3ZBNou5EFH3iRb0vAp4YIC3 N70Qy0j3lFysJkO3Izblz+gHyN3tjhkRbzjeUojmKzv6qJttIbQHE57fKP3i5hfqYo79 a6uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Qk1R7MqZ; 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 34si15347761plp.305.2019.06.12.01.57.07; Wed, 12 Jun 2019 01:57:22 -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=Qk1R7MqZ; 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 S2437212AbfFLIdI (ORCPT + 99 others); Wed, 12 Jun 2019 04:33:08 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:46060 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437205AbfFLIdG (ORCPT ); Wed, 12 Jun 2019 04:33:06 -0400 Received: by mail-pf1-f195.google.com with SMTP id s11so9197424pfm.12 for ; Wed, 12 Jun 2019 01:33:06 -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=Qk1R7MqZa9Gr9tjkCwl11RalVFSB915VNouBPrvwfBO9lorQBbp7X8Jyd7aga+98Rl FihMvVAZ8/EgFppumiMRcEQOdszZMnsM7re1t8uMnibI8np0u0Ydu8U74WWnwVUT7wXN AqVAf+cQdLwcy3UGMuga4TH5Fx3iWaA3KOKXPtlAYTdH1ng3iI+hAdHIEFotqb76HTJg yHnaoqMiTpAEpvppbim/2mKz8Xss5BrdGX8y74VPTi26CkqWljTS8aCH+Jul13rGjLd3 zP+W3p5eMiEMWjqVbyfmLzQmVd6cVYHQAUmkpSYxS2QiU18Hxy6bzHflTAibffmeJ/BW lt9g== 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=GE1JFakKdTnHwj8upldbgjjLtxPdCahbWE1aD6TeeYlfpqFak2/k92sNqP+r0CxTLI GKQ3p61R/S0aHvw4imk1kN/rZL0+etg4XakkO7gBmQxg4AMp3uAjEHzZ0ofMeA4bQd8M 4+54SwXfrYhgBroSjjdrx5ZvMm1NbddVucgMKY47S31QbIQnEqFIodZJTQq+p0rs2koM ODLYMtLHUEcvdr+EKu42icj0efq830N8P3iyWelra4C1zWf9hwci1A3ZSY/CKFppmUis Os4bVJyEX6iHhDFwapbGI7dSnYZCaMhG1MWQw07hOodgjnVWlpq/rd8co3s5T0IjTd/z GTaA== X-Gm-Message-State: APjAAAUyBTLEMB1yaOnwK1cqaSEjPtb8KJXy3jJtgQQkQKM9x9UqU6YV WxixDiz4HWrmeXidwFtdvbs= 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 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 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 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