From patchwork Thu Feb 15 10:28:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerome Brunet X-Patchwork-Id: 128405 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1588796ljc; Thu, 15 Feb 2018 02:28:41 -0800 (PST) X-Google-Smtp-Source: AH8x227HcYig7Pq0A567LrIrFdz3quNIQXj/9BEZDFe/sK9Gl8tq8Ky4sMEw4bKCA/6Z0Q8U2M1+ X-Received: by 10.99.113.75 with SMTP id b11mr1845124pgn.271.1518690521550; Thu, 15 Feb 2018 02:28:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518690521; cv=none; d=google.com; s=arc-20160816; b=ofXhGLYYvgYwVdmg5E0tSfs9gmZPvknFyJ8nFF5cZX038xws97XrttJJ2nVq5UBYZJ QRTvC/HjyQgpXls4D5aY3gTsbh8xlE3S2jqfGO/kUHYq04+U59m1DjlwQ/CGBe3dGJcK 9J5A102HexW/GVm38iN2FxIhsnI1v3/H6mmmx5wTR876OxoSwmarYKPj17GTJmKUI/ZM 7Ykj0D/aM/dgrh2hOF8Ax2Nqq2VNXhaE+XgIVP8JmM7LCumMpy7u3wQexwKLxcXrgCIR xH76pDFbdrwr6VeKjqFFoyuVCUYh93dzPjvobY4aCBpQD/eH/NHL8qukRuAjt9pq9fve lY0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=hEJas9ABHliWL/J8I7xF1iVBfSSLB9bc7bzNx+G8pR4=; b=tt+NzDdo3fmg1YYx6SkSpn0NaqOSwxvcOX1YnXyBYEiWu8vew3b6w4W+jpQIv5Jor8 6d6KbLK/uqmmuzHJ0JboF/L3ozzS0MEAMdOe9kUbKe6Qx5TuK+tfYfQTomwyEHvkWRxn Sae0XDCnTV91SgoEXhh4LCTRc7B3IRHYfbV2P27qWDRTPu+6Co7N3ACvyYmBpRe7Vvzl vscFWkrp8nxdacioqEIAspdcHwHobT5/+z1GDnsovqJQEKzWRBxlkgTmp9UkVcSKmYNe KnKN/28A2FNeOPsEBVlUbIHoSe2I4CnLYLf3wWNF+FE3o7cNjMs9LajxBVqwtin/lWih nAXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=OEDiOoQ1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m12-v6si3197087plt.170.2018.02.15.02.28.41; Thu, 15 Feb 2018 02:28:41 -0800 (PST) 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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=OEDiOoQ1; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755426AbeBOK2i (ORCPT + 28 others); Thu, 15 Feb 2018 05:28:38 -0500 Received: from mail-wr0-f196.google.com ([209.85.128.196]:43594 "EHLO mail-wr0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755304AbeBOK2f (ORCPT ); Thu, 15 Feb 2018 05:28:35 -0500 Received: by mail-wr0-f196.google.com with SMTP id b52so2781430wrd.10 for ; Thu, 15 Feb 2018 02:28:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=hEJas9ABHliWL/J8I7xF1iVBfSSLB9bc7bzNx+G8pR4=; b=OEDiOoQ1KXxcOPRriBVONbQobl3UdU6HF8E/VqsVJQrlFifyED2gr6V785GZs/PjoS QbtyAKmkWVN6+jdKOxkSU8twO9Zhcx9+MUQNav8XSmJ2AH1p5kXgXSbQqSxKqtlzjG84 RKLqC0jUs9lJXRgaFkL0O/+SrYa/QPajt3kc71p/MazhWYql8StU+ggfadgJNKe9JiX9 9LyaQ70RQTVXWWjJQRTvop0mNLWUcTxeMDSHT57XwZNlyfT5+DNt3HjRtLL1UAgoSYd5 RPmivmTZiABn9tRYgac1vdu/KnFjtmmWaOHrI8XD+TC4a22Z6yKz8WgUG0Umo/BLhKdH OTwA== 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; bh=hEJas9ABHliWL/J8I7xF1iVBfSSLB9bc7bzNx+G8pR4=; b=TsTR2QKxxhFYFSXgsUJ0QDmXdty9pRMFx259o6pq06B5X6kR6wLup6MvRM99LaIItc DEo6e7HinWOQEPo+39Vnt+LBRD7Vip6scPEAiQm+DiSbKYhw7PN5EokPz2YI36g6bWY+ P0ixGNpQAMWkrDs7JfVHHU7ml4M5SsfmElVEFa9bccxtQ4S/kHt/2zSJ5zNfR+zs8puT 9DZadv5jtInkTh6Or4lZnMXJeUCumJ3fWc6aWCHx0CwevtCGxJ1DWqO33/AxM3E+yrpW pTaGOlFRgvSZplwcw8AYr+rQ/n8MxJZkCf0zfTkLqAI37UdaZImy49Q/u1YQwr0bB1w3 RT/Q== X-Gm-Message-State: APf1xPDz5ZjEAgzscvd1tOYwtgxrBYhWkr3net+/ywkip8NQztFFvq31 2lWgYYoc+Dq3M0Kd7ewNT1IB5A== X-Received: by 10.223.139.68 with SMTP id v4mr1991804wra.157.1518690514683; Thu, 15 Feb 2018 02:28:34 -0800 (PST) Received: from boomer.baylibre.local ([90.63.244.31]) by smtp.googlemail.com with ESMTPSA id u79sm17283556wma.10.2018.02.15.02.28.26 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 15 Feb 2018 02:28:31 -0800 (PST) From: Jerome Brunet To: Michael Turquette , Stephen Boyd Cc: Jerome Brunet , linux-clk@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] clk: use get_phase() if available Date: Thu, 15 Feb 2018 11:28:22 +0100 Message-Id: <20180215102822.7721-1-jbrunet@baylibre.com> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When the get_phase() callback is available, we should use it instead of just relying the values cached, and assumed un-rounded, by the framework Signed-off-by: Jerome Brunet --- Hi Mike, Stephen, This changes applies on top of the phase fix I've sent [0] [0]: https://lkml.kernel.org/r/20180215101958.22676-1-jbrunet@baylibre.com drivers/clk/clk.c | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) -- 2.14.3 diff --git a/drivers/clk/clk.c b/drivers/clk/clk.c index b33d362239e7..bcd6ec980903 100644 --- a/drivers/clk/clk.c +++ b/drivers/clk/clk.c @@ -2297,6 +2297,21 @@ int clk_set_parent(struct clk *clk, struct clk *parent) } EXPORT_SYMBOL_GPL(clk_set_parent); +static int clk_core_get_phase_nolock(struct clk_core *core) +{ + int ret; + + if (!core->ops->get_phase) + return core->phase; + + /* Update the phase if the callback is available */ + ret = core->ops->get_phase(core->hw); + if (ret >= 0) + core->phase = ret; + + return ret; +} + static int clk_core_set_phase_nolock(struct clk_core *core, int degrees) { int ret = -EINVAL; @@ -2314,12 +2329,16 @@ static int clk_core_set_phase_nolock(struct clk_core *core, int degrees) if (core->ops->set_phase) ret = core->ops->set_phase(core->hw, degrees); - if (!ret) + if (!ret) { core->phase = degrees; + /* Read back the phase in case it got rounded */ + ret = clk_core_get_phase_nolock(core); + } + trace_clk_set_phase_complete(core, degrees); - return ret; + return ret > 0 ? 0 : ret; } /** @@ -2375,7 +2394,7 @@ static int clk_core_get_phase(struct clk_core *core) int ret; clk_prepare_lock(); - ret = core->phase; + ret = clk_core_get_phase_nolock(core); clk_prepare_unlock(); return ret;