From patchwork Fri Jun 7 04:45:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10980919 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 B560F92A for ; Fri, 7 Jun 2019 07:44:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A6360288F4 for ; Fri, 7 Jun 2019 07:44:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9ACCA28A5F; Fri, 7 Jun 2019 07:44:49 +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 43B5F288F4 for ; Fri, 7 Jun 2019 07:44:49 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9A8A989B00; Fri, 7 Jun 2019 07:43:48 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id 43CF88940F for ; Fri, 7 Jun 2019 04:46:28 +0000 (UTC) Received: by mail-pg1-x541.google.com with SMTP id a3so486431pgb.3 for ; Thu, 06 Jun 2019 21:46:28 -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=dNHTk/h7L0i2bfnWDM1CgdFtcXeIxjoq/f1frKTneXZplDa7VuQspLP6wKfYY4/suX XPyOjHtKOsdwf2glw+oD81x8ywgAquGulk1qQNTO2D5cmGJ0EQXYImVzM6YbrM07vEWN iY7QdBu9N3h+0olhnuyDO90YESjrZxEPJ3dbXYw6DtAWX7I35ZtDKjhojGIGed7KIOfS xy8ZdoIYrsfD7Wb4bUmrRnj4zZXZm6+php9eprX+xSzPDwJ8HI+Pcp3s+FPLYK2gFFqI 0OI2iynvnEIrM/wKUR/eAiy1M1dFPe24lXQgDTPEzQNFP5G9I2DxC52mqlQQjd2vGh7A aIug== X-Gm-Message-State: APjAAAU4ovT5JT9FkwdXc6+dBRkgzSKiYbYJM94UBgNmpbR4Qodn69oC IOPozbAzx0+/+UF3EtuiiBfmg3bjCVo= X-Google-Smtp-Source: APXvYqwV5NWcrH8Cyv0S6V6xQPqPc2nmpXhlBkIeb3FQQVZmdvJW0wISblYzI8nqFbA75XSoSrsBBg== 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 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 X-Mailman-Approved-At: Fri, 07 Jun 2019 07:43:40 +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=NbXke3b2qlDIEr+OgQCHGhnfYfyjuzBOi6Vmzc5+N4u29mWad7c/5SHCexsVl7NS2o 4AZjKAuB5MYldANKtxvXX0lFzwDKQokVj1+RDxXXJEfm+fWjTAKT8lYCT4FdDq8rmuz9 2KAUECG3ExiflZfBRN4PI25kaPLqE/oyG0dA3CFcAKvzoOigS2zbgpoBPrFEbA/lvPIo pB0JbZjLaFtQOXPqdnUnvioHkjKMsoNrxqNaAfUhblKMQrksKByyMBvUnh+Ue7BF6up6 8LvVFCB31XzcRzqpWWCOZvbhFdqks4VGrYoktF0unxDIEbt69s2K67FwN6JWjBR1ytX0 /Wog== 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;