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: 10220827 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id D8A34601E7 for ; Thu, 15 Feb 2018 10:28:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C507728714 for ; Thu, 15 Feb 2018 10:28:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B940A29117; Thu, 15 Feb 2018 10:28:38 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0459F28714 for ; Thu, 15 Feb 2018 10:28:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755308AbeBOK2g (ORCPT ); Thu, 15 Feb 2018 05:28:36 -0500 Received: from mail-wr0-f193.google.com ([209.85.128.193]:37449 "EHLO mail-wr0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151AbeBOK2f (ORCPT ); Thu, 15 Feb 2018 05:28:35 -0500 Received: by mail-wr0-f193.google.com with SMTP id k32so2803318wrk.4 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=U1WyD/fFW/bAPLto2VewCEUcJkhvE6vzTZ6UXqiNj6yzqRGY2rlsIVIqZLYZOgGqea YjntdjNStk5r+5H80XawcDb2hiibZDxHRMZ3ihzo9jDVz/jZ2tU1EBwHbcdE68egH7/2 0hYc5dVdSGENQm2Wi8iUQbnau+1gnu2ubG7o7fBswt7vJBqJmDes9uyPMdM+/+lAYVa1 Umyfd51uyKJfiFWnnotZ9oQh5beFw1954waroH9Irzgow8lk+uVn8l7973xRKgIZXqUH xm9Uuc5XqXna293kdFJ7RTYyHSClfE54gq56jiLuR/MR4wPeBWqnKMn4tykv+j8cLrqK kavg== X-Gm-Message-State: APf1xPApgnz/UhJG1qEFNDBys6DTqg+omzO/xbCV3HpPlik4ITVKncNt rdAfmRAQ7EqQznE6ebhEqPkdCA== X-Google-Smtp-Source: AH8x224bWNDWHhlMDkNqzW/C0kHqR9jiJ74APwJDjCrYnagKH3CIBcPToy0/bI+RkNo2adnc91iHFA== 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-clk-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-clk@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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;