Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp6014imm; Tue, 25 Sep 2018 14:51:21 -0700 (PDT) X-Google-Smtp-Source: ACcGV61jQYpmWTJ+m4mcqKT13p445WYoePfNLKAeyjRNQkfqIzYy09vuQFjoXbJywbjX/YFECVtV X-Received: by 2002:a63:380d:: with SMTP id f13-v6mr2829540pga.124.1537912281770; Tue, 25 Sep 2018 14:51:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537912281; cv=none; d=google.com; s=arc-20160816; b=Y+q+EzlsnngftxgpNJf/EXezJDK4XOEBgsJ3iUtAK9/it9wCSKp99KZNJLdFF4TwGu mTW9V53aQPmDlnY8Szm3VHwDYvJD98GMwSd9Pt8p6hfSqemOByfkR2bQ4QSAy/sQut3S E1MYLPvCY9oKnbq/9kp2V/X/QCuFJ97JZAlSJ5thL5e0L3M32dt15SrjaNA82yzzc/E3 M7Cem1UaJ7dqPp4zvcDyFYNdnoFo9rbkGz64MnvUiAIzMhVaVKZdWwVOeFomCW/tT5hA K82YevnDorQrwz4WZB7vP71dIQWYex5mjNN4iSxJ4zXTv0IzWwxqzfTgHKay+pOnJGxe dnwA== 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; bh=ysfSkpixO2yl8uMGR1FCWmHvdez/6Jg2aRagge3VwsU=; b=V5KKe7u5HqbmBjDxXIy/EBzKWlvBCmpmuEO3Qmj5qEdxKF4JBYJxUe1mrV+3vQurU+ q1lfSxNb3TR2zqu6wj7ERS2LKurVCmW6TzWQNMK7GQ+xjM2/AGVbyDiuq7VjJ48DUTCH y1cqfCsz4Xl9839VACqgddhWGFFxV6oM+RvA4uxXIezE06BAT0IpA2Toms/tPggLmoyn nQGtiaV8JlkluD2s9LWpIj0ByJxUWyMYVxy5x6FP8XA/ZMLQ6w/JhfbOrhqSz8YBq4G+ +n6+RNQrkRIDmXKrJCJNANWNwdC1GhbVrEwokDk81733CvMjMPx8gxATIUuSRprwsis/ dv5Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=jBbFAUWb; 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 bg10-v6si2345205plb.47.2018.09.25.14.51.06; Tue, 25 Sep 2018 14:51:21 -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=jBbFAUWb; 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 S1726991AbeIZD7l (ORCPT + 99 others); Tue, 25 Sep 2018 23:59:41 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:40740 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726497AbeIZD7l (ORCPT ); Tue, 25 Sep 2018 23:59:41 -0400 Received: by mail-io1-f65.google.com with SMTP id w16-v6so3588755iom.7; Tue, 25 Sep 2018 14:50:05 -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; bh=ysfSkpixO2yl8uMGR1FCWmHvdez/6Jg2aRagge3VwsU=; b=jBbFAUWbb4xkEO792L3X5JCO5yWP6VIu45P0DL7N0Ixo8uJ37ADKtmoKzYU+u5Vo8Q 8dGHGi44/RIDAluh+TGlQghv++nRzboupvH6rkBT6eRHkMmch1DtrPLB20yo28ntBfwG s3tVlK0Mt8XgLOhThSCLAJqd/BY9p+ken7lESBlE6Kb+eK2iYIuDy8KUrXiUYsxlc+jn mJNxgo+pSj6mkUadSLhMyoYioX7i97JUyIiGq16NeV0i/h7O31ZxH+rKyzifpZNh3cYF f2HIlyVQxAVwkha0Jb6Pwr1/BmmAalrZdQjFYDx0LDL9+icXBYUAPLsXRkX/TMcsI131 gCCg== 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=ysfSkpixO2yl8uMGR1FCWmHvdez/6Jg2aRagge3VwsU=; b=KhRXgHXv8ghRN3nh+xaaCYhShANB8uah3CD0DrtAfNJhmxlGt2XpdACWpmPiednlww z/eN5fA8L3UxpcJzDApexYXO6w4GrjK61pOfME7LaQehBAdxZXARMyHZc6Qmj0RDXKqL XH5AOafWq1l10oOFZeyClH5ZOOw0oN4Evi0ZnRouOmpwNIcL2yXizFX4DnYHlXAWePqL R5LmxA7LeB5xR1bfjMdBJ8YYTV3xBPaWKAu7oHz7dSSIhZJJ1ERydlVaBrtIcVcgRjJB x2iByvUflM0p+2hXrgDDD6ESXbZm9f2MW5k08e4I+awjae0TTrbTsbs+WJDlT9faK4b2 OBuw== X-Gm-Message-State: ABuFfojsN7yfVlNnnIwrfDwQSd+oqzBYcmU3Z07Ms/BhCJzlyfhgFing OVuL+AaX7V87d7otkm/n6g== X-Received: by 2002:a5e:d612:: with SMTP id w18-v6mr2811602iom.54.1537912204620; Tue, 25 Sep 2018 14:50:04 -0700 (PDT) Received: from localhost.localdomain (CPE1cabc0918a93-CM1cabc0918a90.cpe.net.cable.rogers.com. [99.229.26.117]) by smtp.gmail.com with ESMTPSA id w193-v6sm1519981ita.11.2018.09.25.14.50.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Sep 2018 14:50:03 -0700 (PDT) From: Robert Yang To: Peter De Schrijver Cc: Prashant Gaikwad , Michael Turquette , Stephen Boyd , Thierry Reding , Jonathan Hunter , linux-clk@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org, Robert Yang Subject: [PATCH V2] clk: tegra: Return the exact clock rate from clk_round_rate Date: Tue, 25 Sep 2018 17:49:40 -0400 Message-Id: <20180925214940.15188-1-decatf@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The current behavior is that clk_round_rate would return the same clock rate passed to it for valid PLL configurations. This change will return the exact rate the PLL will provide in accordance with clk API. Signed-off-by: Robert Yang --- Changes in V2: - Move input divider (m == 0) check into the cfg constraints check condition. Forgo adding WARN_ON and avoid using 0 input divider all together. drivers/clk/tegra/clk-pll.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/clk/tegra/clk-pll.c b/drivers/clk/tegra/clk-pll.c index 17a058c3bbc1..2a800a9c56e6 100644 --- a/drivers/clk/tegra/clk-pll.c +++ b/drivers/clk/tegra/clk-pll.c @@ -589,12 +589,13 @@ static int _calc_rate(struct clk_hw *hw, struct tegra_clk_pll_freq_table *cfg, cfg->n = cfg->output_rate / cfreq; cfg->cpcon = OUT_OF_TABLE_CPCON; - if (cfg->m > divm_max(pll) || cfg->n > divn_max(pll) || - (1 << p_div) > divp_max(pll) - || cfg->output_rate > pll->params->vco_max) { + if (cfg->m == 0 || cfg->m > divm_max(pll) || + cfg->n > divn_max(pll) || (1 << p_div) > divp_max(pll) || + cfg->output_rate > pll->params->vco_max) { return -EINVAL; } + cfg->output_rate = cfg->n * DIV_ROUND_UP(parent_rate, cfg->m); cfg->output_rate >>= p_div; if (pll->params->pdiv_tohw) { -- 2.17.1