netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jacob Keller <jacob.e.keller@intel.com>
To: netdev@vger.kernel.org, Jakub Kicinski <kuba@kernel.org>
Cc: Richard Cochran <richardcochran@gmail.com>,
	Jacob Keller <jacob.e.keller@intel.com>
Subject: [PATCH net-next 1/9] ptp_phc: convert .adjfreq to .adjfine
Date: Wed,  9 Nov 2022 15:09:37 -0800	[thread overview]
Message-ID: <20221109230945.545440-2-jacob.e.keller@intel.com> (raw)
In-Reply-To: <20221109230945.545440-1-jacob.e.keller@intel.com>

The ptp_phc implementation of .adjfreq is implemented in terms of a
straight forward "base * ppb / 1 billion" calculation.

Convert this to the newer .adjfine, updating the driver to use the recently
introduced adjust_by_scaled_ppm helper function.

Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Cc: Richard Cochran <richardcochran@gmail.com>
---
 drivers/ptp/ptp_pch.c | 19 ++++---------------
 1 file changed, 4 insertions(+), 15 deletions(-)

diff --git a/drivers/ptp/ptp_pch.c b/drivers/ptp/ptp_pch.c
index 7d4da9e605ef..33355d5eb033 100644
--- a/drivers/ptp/ptp_pch.c
+++ b/drivers/ptp/ptp_pch.c
@@ -336,24 +336,13 @@ static irqreturn_t isr(int irq, void *priv)
  * PTP clock operations
  */
 
-static int ptp_pch_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
+static int ptp_pch_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
 {
-	u64 adj;
-	u32 diff, addend;
-	int neg_adj = 0;
+	u32 addend;
 	struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps);
 	struct pch_ts_regs __iomem *regs = pch_dev->regs;
 
-	if (ppb < 0) {
-		neg_adj = 1;
-		ppb = -ppb;
-	}
-	addend = DEFAULT_ADDEND;
-	adj = addend;
-	adj *= ppb;
-	diff = div_u64(adj, 1000000000ULL);
-
-	addend = neg_adj ? addend - diff : addend + diff;
+	addend = adjust_by_scaled_ppm(DEFAULT_ADDEND, scaled_ppm);
 
 	iowrite32(addend, &regs->addend);
 
@@ -440,7 +429,7 @@ static const struct ptp_clock_info ptp_pch_caps = {
 	.n_ext_ts	= N_EXT_TS,
 	.n_pins		= 0,
 	.pps		= 0,
-	.adjfreq	= ptp_pch_adjfreq,
+	.adjfine	= ptp_pch_adjfine,
 	.adjtime	= ptp_pch_adjtime,
 	.gettime64	= ptp_pch_gettime,
 	.settime64	= ptp_pch_settime,
-- 
2.38.0.83.gd420dda05763


  reply	other threads:[~2022-11-09 23:09 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-09 23:09 [PATCH net-next 0/9] ptp: convert remaining users of .adjfreq Jacob Keller
2022-11-09 23:09 ` Jacob Keller [this message]
2022-11-09 23:09 ` [PATCH net-next 2/9] ptp_ixp46x: convert .adjfreq to .adjfine Jacob Keller
2022-11-10  8:14   ` Linus Walleij
2022-11-09 23:09 ` [PATCH net-next 3/9] ptp: tg3: " Jacob Keller
2022-11-10  5:23   ` Pavan Chebbi
2022-11-09 23:09 ` [PATCH net-next 4/9] ptp: hclge: " Jacob Keller
2022-11-09 23:09 ` [PATCH net-next 5/9] ptp: stmac: " Jacob Keller
2022-11-09 23:09 ` [PATCH net-next 6/9] ptp: cpts: " Jacob Keller
2022-11-09 23:09 ` [PATCH net-next 7/9] ptp: bnxt: " Jacob Keller
2022-11-10  5:24   ` Pavan Chebbi
2022-11-09 23:09 ` [PATCH net-next 8/9] ptp: convert remaining drivers to adjfine interface Jacob Keller
2022-11-09 23:09 ` [PATCH net-next 9/9] ptp: remove the .adjfreq interface function Jacob Keller
2022-11-11 12:00 ` [PATCH net-next 0/9] ptp: convert remaining users of .adjfreq patchwork-bot+netdevbpf

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=20221109230945.545440-2-jacob.e.keller@intel.com \
    --to=jacob.e.keller@intel.com \
    --cc=kuba@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;
as well as URLs for NNTP newsgroup(s).