Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6400014ybi; Wed, 5 Jun 2019 00:06:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqyt3jwbiuO4GvqbF/8GTC4Ow2TzSgLmPeh8Pm1jwCK/98UWLiq0SEFcwDqWNDyUEJF+Kg4p X-Received: by 2002:a17:90a:ca09:: with SMTP id x9mr41435490pjt.105.1559718412842; Wed, 05 Jun 2019 00:06:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559718412; cv=none; d=google.com; s=arc-20160816; b=QALk31uEd8Zdf/9kkADwTg7SupIxMWaNtM+EmsFYHdB5+tgwbEFqjKPjJeN/SMFXFw q7BRa1s7WLhCkvdCDBVkl9cJkW+5fXbC/C+ZqBMwH5v10Al8R5t7vtEPKH2kMQLh4peY yKN2cXh1bcVCq7bHHbY3RhmcclKqq1TT6zkwomNisgfhn3IFX0r9lZGMlmMbhJernAwd gn4JGsbUULQkGKScgYH5qWR1HMCBeLKv7P8vEn3JlH5ZWp+5LQdHLJ61FgUwSX7pOUyF 5YIf4YGMkm3jdwR53hEZ3wCqp+oGFsUjVPHviiiK3wRnG3dLc0QwtCmflcfIGQmQZ9fM Mk4A== 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=XgORgJz2civFnf3JPNeTbcWwHZBa/hdHBoQiM2otHkM=; b=MBbafJ92M/XU350rDx/XUNEUw8/+0CL4sIeNwEsWwfKVpG6i8btTnUYoErgpzfm4N7 arf81VLtObsqcptcH1B4dEhg+JXqsV/Y5atBWmZJtYeoo9SSgbamDSjBeGCxI22YTqJl aO4pnoW3L76jgChTreqCuQN1C9kFe7sX/HSFUnuZauNacKHxON46/5XNrab5k27aebFp Bcf+uAkKP6cDoCARbRykMz3AZN3sho9DTYHzl6OU9decm9Z96xk7+3hQC9XJG0bjsYQs 2UmopSljdPMlYJMdvvsQGhHsuGoemQ3tljyXz6e6JTlWe7Bn8YP+REAFyQ/cabvvkmwO GTLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eH00neYS; 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 a59si27324738pla.348.2019.06.05.00.06.35; Wed, 05 Jun 2019 00:06:52 -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=eH00neYS; 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 S1726668AbfFEHFZ (ORCPT + 99 others); Wed, 5 Jun 2019 03:05:25 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33895 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726086AbfFEHFY (ORCPT ); Wed, 5 Jun 2019 03:05:24 -0400 Received: by mail-pg1-f193.google.com with SMTP id h2so8634160pgg.1 for ; Wed, 05 Jun 2019 00:05:23 -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=XgORgJz2civFnf3JPNeTbcWwHZBa/hdHBoQiM2otHkM=; b=eH00neYSh7+Uuk3fa+0te52F39630X0h9Ql8M7fGODiNzU+dGyrfpLzY/c1ql48tEN xMkvrpa9uaq9N5gKz2eCSl2GfmxoZYnWz833Z9ZOxKg3962WaT/9KHL0V2SehgOv1PlH eoDaPIhIp79QpqJ7sERYNmopyo5lhYtixOdwGpE9LJHrsJ9TQMjPzUAOAm8++0YDC/Gf sQCIo2JRunRuqVmcx4w+DF3Nj/S5dkr9kUVRYRsga1+b7aB1WoN/VRcfZruB+CKWsPU9 Hudm4D6yKAfwnhaVIU6q/m1DUmVrLkQo6GPfwbM+J7G8jtsBKdE7dG1gLhu73HcfSi2j 9ONA== 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=XgORgJz2civFnf3JPNeTbcWwHZBa/hdHBoQiM2otHkM=; b=QiL6pmgcnmlK8B52KGR5A7EO/Wj3UJXenY7yFrmHkb0Ndftx0a9N+S/Bq4P7LzUt8Q 2lOdnz+oa6HAhLAcpKhIqkQ0XvowPc3oTMnhWqB2QGuBHidMbMiaicLVHvQ3TN3ZSZu0 aaU/uIb6Hiy+hXY0zAcw5xzjgQdQsWZ9hbNau07NHvGHO7dz9jLXNskrpehnOLt6jIBN WhGmA+t3cY0WJ11S1P8sPP/QnyHH9kLAMUVFUtjfFm85FGGRR5OvGv6lRLLI1r8C2yB1 12qRRTW4rfZj6pQUtkkeovtJdEZTlRJjfDZ0V2mPqhPeoHaCVtdeVWmQZzzrWzQonTiv JMww== X-Gm-Message-State: APjAAAWRK/LHCISt5/KoORXSh9sZJ7wJhmXekQ8Lrt/joJhk0qVBQJtw pqoFdXBjbkXw+FMJ9FuhstI= X-Received: by 2002:a63:e358:: with SMTP id o24mr2409745pgj.78.1559718323398; Wed, 05 Jun 2019 00:05:23 -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 d132sm6527348pfd.61.2019.06.05.00.05.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 05 Jun 2019 00:05:22 -0700 (PDT) From: Andrey Smirnov To: dri-devel@lists.freedesktop.org Cc: Andrey Smirnov , Andrzej Hajda , Laurent Pinchart , Archit Taneja , Laurent Pinchart , Tomi Valkeinen , Andrey Gusakov , Philipp Zabel , Cory Tusar , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v3 01/15] drm/bridge: tc358767: Simplify tc_poll_timeout() Date: Wed, 5 Jun 2019 00:04:53 -0700 Message-Id: <20190605070507.11417-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190605070507.11417-1-andrew.smirnov@gmail.com> References: <20190605070507.11417-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: Archit Taneja 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