Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp285676img; Thu, 21 Mar 2019 20:33:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXfTuvCnv+u2zGkDM2Bo8OixAzLhs3hY02JGBoSfSXzGmCue/yejxGktaCabaXLPiH6mD3 X-Received: by 2002:a63:f850:: with SMTP id v16mr6673489pgj.448.1553225589055; Thu, 21 Mar 2019 20:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553225589; cv=none; d=google.com; s=arc-20160816; b=IqwoSqr9dMYup1QQahfukLMPPPM2JUqxVhGs7mMpZ0cKKAIiyshgvQM2BgQiEDSkWe jS8tauf3HWIiN1LeN5aCUtSDPMRIYbEcLO/R1gr5a0AVs+pKo0wZUbY9zrIgd1w4lDdw ysJFFc7Fl0TsPS4XjACLXwWxGkI3Kt3U3dy39FG9HxzMmxhH4PELOlaEYjNuR49wBiDz EFIAPYA3KLcGEUQshYzrcbOLUWdLwCAFwA51+8DrMDK7zf9cSrvwNvOccD6XYPeZaxud Sw0vOdXyOSKrRRNVnWwvod0e4iqTG3WxcF9ra1/nUOsD5VLez1muOqyPklxWKx0DWZqm f5Vg== 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=JPSVcf+dfvV2lEaXqE0Y3BqqEMdwT4aIXnO4VFTAii4=; b=uSYIq2Eo/DcujBuhQ4uLn1ida034Fllb+SzgS4yDHGH9qPBm6cUBlJ7cQEdmetWpB/ SqpF8abY/XdkRZbFqG3AMvhBkzjNp9+u4Mnjz3TaAlQfqMxOsgakthZMha90sLiEXVsL AyzeoiiE+nULy74YnpPCV+hjX9LGwQsZoivBqiU7A2mdjUtqtO0nUq6u+AmophXckzX8 2AoABn/9i7pJAhRPsr8stmVvJFv1WLV8p05NttcEQ0QHQqySeM2nP8pBLdM8yzHhkE2+ jKmNUVGmQOGzciY9RwsNUGOV9X9/K0sxaw3rbXWi2a2CHr3rGEbKTPKkloM5lWyGM9by J0aA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Y6hf30br; 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 v41si6471998plg.8.2019.03.21.20.32.54; Thu, 21 Mar 2019 20:33:09 -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=Y6hf30br; 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 S1727606AbfCVD3S (ORCPT + 99 others); Thu, 21 Mar 2019 23:29:18 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:43798 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727222AbfCVD3Q (ORCPT ); Thu, 21 Mar 2019 23:29:16 -0400 Received: by mail-pg1-f195.google.com with SMTP id l11so484845pgq.10 for ; Thu, 21 Mar 2019 20:29:15 -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=JPSVcf+dfvV2lEaXqE0Y3BqqEMdwT4aIXnO4VFTAii4=; b=Y6hf30brOL+wOWTz7vL8GCUFl8DNj6a8LAREJ/5QHZMMjy3qeQDGjarGn8XZiGxIad CCBvgA4fsFGLLPf8sRpmVbZ1HeU6I7fbTGWJV7WzRbYBggwecEWd66GQe+iJnNTRIDXT f60eqBiIsw3j5PwEazlePVcNWA1H3CytBIcIwn2oAAkK28kkbQFFWsDsWEnyakRjIo/G skHiJrJ8uOtqLsEkfEvlMlAJowApzvE4CZKQiXpOQKMeJjoKn1qXPI7PLsiZPfwaZEVg ehmuirYb7IZCpwd60ZEuy6k5GZKO9uuOmGx9uqdZlKvV9H7Vcm4jb95g2AS9ov1TDLs7 BOLg== 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=JPSVcf+dfvV2lEaXqE0Y3BqqEMdwT4aIXnO4VFTAii4=; b=pTUN3mlHjV8M6SwgL9NtMeUjto/nM/9ehffrQzrKhIEDLIZfBxQFRyVs5B6yW2upjz /YYOHTBNWSh8RPnyfI3s1CKT08h7Xk1h55IOxXMOdqBVGjF59zyu5CcCYtwU+W6ZgI60 FtjH7yAbKM25UZ5fTc67dyWav9sHFu8BkgaJbsuaxKA9/pPZuXJQdqDn/WMnhRsyT0dJ bPjP7ya5tqaoHPOD+LwKxiBGKD0Lg8FVNLAynCa/9fZ8WQOR7IhPCDlfpXPbRkMLOt81 OGZFt9jnVFPo2JVtpqjHb1awXl1b41MX+/9+XbsP29q3gjJDUptlzkiX+ceAhZ9ccmcV YHkQ== X-Gm-Message-State: APjAAAUjdNkBFpOCJMCI1UobxWmMUGHqsjbzH09HsQSZ3OoLsNqXM8fe also86PAGDipyVLVAFeWIPI= X-Received: by 2002:a63:d5f:: with SMTP id 31mr6691138pgn.274.1553225355378; Thu, 21 Mar 2019 20:29:15 -0700 (PDT) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id o76sm16154476pfa.156.2019.03.21.20.29.14 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 21 Mar 2019 20:29:14 -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 , Chris Healy , Lucas Stach , linux-kernel@vger.kernel.org Subject: [PATCH v2 01/15] drm/bridge: tc358767: Simplify tc_poll_timeout() Date: Thu, 21 Mar 2019 20:28:47 -0700 Message-Id: <20190322032901.12045-2-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190322032901.12045-1-andrew.smirnov@gmail.com> References: <20190322032901.12045-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: 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 51095ab1e996..89a4392dfa35 100644 --- a/drivers/gpu/drm/bridge/tc358767.c +++ b/drivers/gpu/drm/bridge/tc358767.c @@ -250,34 +250,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); } @@ -584,8 +571,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.20.1