diff options
author | Jacob Keller <jacob.e.keller@intel.com> | 2022-11-09 15:09:37 -0800 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2022-11-11 10:58:39 +0000 |
commit | 2e77eded8ec34768618f9ab724b9092e09ddcca2 (patch) | |
tree | 158997846bb15af323b48f4cdf372f3970aa5f82 | |
parent | 3b738db50f9e5c15c161408c3f7a0c86225aecef (diff) | |
download | linux-2e77eded8ec34768618f9ab724b9092e09ddcca2.tar.gz linux-2e77eded8ec34768618f9ab724b9092e09ddcca2.tar.bz2 linux-2e77eded8ec34768618f9ab724b9092e09ddcca2.zip |
ptp_phc: convert .adjfreq to .adjfine
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/ptp/ptp_pch.c | 19 |
1 files 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, ®s->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, |