linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Abel Vesa <abel.vesa@nxp.com>
To: Stephen Boyd <sboyd@kernel.org>, Stephen Rothwell <sfr@canb.auug.org.au>
Cc: Lucas Stach <l.stach@pengutronix.de>,
	Michael Turquette <mturquette@baylibre.com>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Abel Vesa <abelvesa@linux.com>, dl-linux-imx <linux-imx@nxp.com>,
	Abel Vesa <abel.vesa@nxp.com>
Subject: [PATCH] clk: imx: Use do_div in SCCG due to 64-bit divisor
Date: Thu, 29 Nov 2018 23:50:22 +0000	[thread overview]
Message-ID: <1543535413-1256-1-git-send-email-abel.vesa@nxp.com> (raw)
In-Reply-To: <20181130090325.7526140e@canb.auug.org.au>

On arm32, a division with a 64-bit divisor has to be done through
do_div() function otherwise there is a link failure like:

drivers/clk/imx/clk-frac-pll.o: In function `clk_pll_round_rate':
clk-frac-pll.c:(.text+0x54): undefined reference to `__aeabi_uldivmod'
make: *** [Makefile:1040: vmlinux] Error 1

Fixes: 9fd680d0fafd ("clk: imx: add fractional PLL output clock")
Signed-off-by: Abel Vesa <abel.vesa@nxp.com>
Reported-by: Stephen Rothwell <sfr@canb.auug.org.au>
---
 drivers/clk/imx/clk-frac-pll.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/imx/clk-frac-pll.c b/drivers/clk/imx/clk-frac-pll.c
index 9872620..8b13df9 100644
--- a/drivers/clk/imx/clk-frac-pll.c
+++ b/drivers/clk/imx/clk-frac-pll.c
@@ -116,12 +116,13 @@ static long clk_pll_round_rate(struct clk_hw *hw, unsigned long rate,
 			       unsigned long *prate)
 {
 	u64 parent_rate = *prate;
-	u32 divff, divfi;
-	u64 temp64;
+	u64 divff, divfi;
+	u64 temp64 = rate;
 
 	parent_rate *= 8;
 	rate *= 2;
-	divfi = rate / parent_rate;
+	do_div(temp64, parent_rate);
+	divfi = temp64;
 	temp64 = rate - divfi * parent_rate;
 	temp64 *= PLL_FRAC_DENOM;
 	do_div(temp64, parent_rate);
-- 
2.7.4


  reply	other threads:[~2018-11-29 23:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-29 22:03 linux-next: build failure after merge of the clk tree Stephen Rothwell
2018-11-29 23:50 ` Abel Vesa [this message]
2018-11-30  2:17   ` [PATCH] clk: imx: Use do_div in SCCG due to 64-bit divisor Stephen Rothwell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1543535413-1256-1-git-send-email-abel.vesa@nxp.com \
    --to=abel.vesa@nxp.com \
    --cc=abelvesa@linux.com \
    --cc=l.stach@pengutronix.de \
    --cc=linux-imx@nxp.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mturquette@baylibre.com \
    --cc=sboyd@kernel.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).