From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbbCVWzg (ORCPT ); Sun, 22 Mar 2015 18:55:36 -0400 Received: from ftx-008-i768.relay.mailchannels.net ([50.61.143.68]:63404 "EHLO relay.mailchannels.net" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751911AbbCVWzf (ORCPT ); Sun, 22 Mar 2015 18:55:35 -0400 X-Greylist: delayed 920 seconds by postgrey-1.27 at vger.kernel.org; Sun, 22 Mar 2015 18:55:34 EDT X-Sender-Id: duocircle|x-authuser|tmlind X-Sender-Id: duocircle|x-authuser|tmlind X-MC-Relay: Neutral X-MailChannels-SenderId: duocircle|x-authuser|tmlind X-MailChannels-Auth-Id: duocircle X-MC-Loop-Signature: 1427064012536:3044401739 X-MC-Ingress-Time: 1427064012536 X-Mail-Handler: DuoCircle Outbound SMTP X-Originating-IP: 104.193.169.186 X-Report-Abuse-To: abuse@duocircle.com (see https://support.duocircle.com/support/solutions/articles/5000540958-duocircle-standard-smtp-abuse-information for abuse reporting information) X-MHO-User: U2FsdGVkX19ABjnE+7bvRaIHo55+suj3 From: Tony Lindgren To: Mike Turquette , Stephen Boyd Cc: linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, Brian Hutchinson , Matthijs van Duin , Tero Kristo Subject: [PATCH 1/3] clk: ti: Fix FAPLL recalc_rate for rounding errors Date: Sun, 22 Mar 2015 15:35:24 -0700 Message-Id: <1427063726-4248-2-git-send-email-tony@atomide.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1427063726-4248-1-git-send-email-tony@atomide.com> References: <1427063726-4248-1-git-send-email-tony@atomide.com> X-AuthUser: tmlind Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org We need to round the calculated value to have it match the requested rate. While at it, let's fix a typo and use a define for SYNTH_MAX_DIV_M as we will need it in later patches for set_rate. And let's remove two unused includes. Cc: Brian Hutchinson Cc: Matthijs van Duin Cc: Tero Kristo Signed-off-by: Tony Lindgren --- drivers/clk/ti/fapll.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/clk/ti/fapll.c b/drivers/clk/ti/fapll.c index d216406..3b5e231 100644 --- a/drivers/clk/ti/fapll.c +++ b/drivers/clk/ti/fapll.c @@ -11,12 +11,10 @@ #include #include -#include #include #include #include #include -#include /* FAPLL Control Register PLL_CTRL */ #define FAPLL_MAIN_LOCK BIT(7) @@ -49,6 +47,8 @@ /* Synthesizer frequency register */ #define SYNTH_LDFREQ BIT(31) +#define SYNTH_MAX_DIV_M 0xff + struct fapll_data { struct clk_hw hw; void __iomem *base; @@ -218,11 +218,10 @@ static unsigned long ti_fapll_synth_recalc_rate(struct clk_hw *hw, rate *= 8; } - /* Synth ost-divider M */ - synth_div_m = readl_relaxed(synth->div) & 0xff; - do_div(rate, synth_div_m); + /* Synth post-divider M */ + synth_div_m = readl_relaxed(synth->div) & SYNTH_MAX_DIV_M; - return rate; + return DIV_ROUND_UP_ULL(rate, synth_div_m); } static struct clk_ops ti_fapll_synt_ops = { -- 2.1.4