Netdev List
 help / color / mirror / Atom feed
From: Yangbo Lu <yangbo.lu@nxp.com>
To: netdev@vger.kernel.org,
	Richard Cochran <richardcochran@gmail.com>,
	"David S . Miller" <davem@davemloft.net>
Cc: linux-kernel@vger.kernel.org, Yangbo Lu <yangbo.lu@nxp.com>
Subject: [PATCH] ptp_qoriq: use div_u64/div_u64_rem for 64-bit division
Date: Mon,  6 Aug 2018 12:39:11 +0800	[thread overview]
Message-ID: <20180806043911.15437-1-yangbo.lu@nxp.com> (raw)

This is a fix-up patch for below build issue with multi_v7_defconfig.

drivers/ptp/ptp_qoriq.o: In function `qoriq_ptp_probe':
ptp_qoriq.c:(.text+0xd0c): undefined reference to `__aeabi_uldivmod'

Fixes: 91305f281262 ("ptp_qoriq: support automatic configuration for ptp timer")
Signed-off-by: Yangbo Lu <yangbo.lu@nxp.com>
---
 drivers/ptp/ptp_qoriq.c |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/ptp/ptp_qoriq.c b/drivers/ptp/ptp_qoriq.c
index 095c185..fdd49c2 100644
--- a/drivers/ptp/ptp_qoriq.c
+++ b/drivers/ptp/ptp_qoriq.c
@@ -373,6 +373,7 @@ static int qoriq_ptp_auto_config(struct qoriq_ptp *qoriq_ptp,
 	u64 freq_comp;
 	u64 max_adj;
 	u32 nominal_freq;
+	u32 remainder = 0;
 	u32 clk_src = 0;
 
 	qoriq_ptp->cksel = DEFAULT_CKSEL;
@@ -400,7 +401,8 @@ static int qoriq_ptp_auto_config(struct qoriq_ptp *qoriq_ptp,
 	 * freq_ratio = reference_clock_freq / nominal_freq
 	 */
 	freq_comp = ((u64)1 << 32) * nominal_freq;
-	if (do_div(freq_comp, clk_src))
+	freq_comp = div_u64_rem(freq_comp, clk_src, &remainder);
+	if (remainder)
 		freq_comp++;
 
 	qoriq_ptp->tmr_add = freq_comp;
@@ -411,7 +413,7 @@ static int qoriq_ptp_auto_config(struct qoriq_ptp *qoriq_ptp,
 	 * freq_ratio = reference_clock_freq / nominal_freq
 	 */
 	max_adj = 1000000000ULL * (clk_src - nominal_freq);
-	max_adj = max_adj / nominal_freq - 1;
+	max_adj = div_u64(max_adj, nominal_freq) - 1;
 	qoriq_ptp->caps.max_adj = max_adj;
 
 	return 0;
-- 
1.7.1

             reply	other threads:[~2018-08-06  6:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-06  4:39 Yangbo Lu [this message]
2018-08-06 17:43 ` [PATCH] ptp_qoriq: use div_u64/div_u64_rem for 64-bit division David Miller

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=20180806043911.15437-1-yangbo.lu@nxp.com \
    --to=yangbo.lu@nxp.com \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=richardcochran@gmail.com \
    /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