Commit 319d77e9 authored by Jacob Keller's avatar Jacob Keller Committed by David S. Miller

ptp_ixp46x: convert .adjfreq to .adjfine

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

Convert this to the newer .adjfine, using the recently added
adjust_by_scaled_ppm helper function.
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Richard Cochran <richardcochran@gmail.com>
Cc: Linus Walleij <linus.walleij@linaro.org>
Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2e77eded
...@@ -120,24 +120,13 @@ static irqreturn_t isr(int irq, void *priv) ...@@ -120,24 +120,13 @@ static irqreturn_t isr(int irq, void *priv)
* PTP clock operations * PTP clock operations
*/ */
static int ptp_ixp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) static int ptp_ixp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
{ {
u64 adj; u32 addend;
u32 diff, addend;
int neg_adj = 0;
struct ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps); struct ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps);
struct ixp46x_ts_regs *regs = ixp_clock->regs; struct ixp46x_ts_regs *regs = ixp_clock->regs;
if (ppb < 0) { addend = adjust_by_scaled_ppm(DEFAULT_ADDEND, scaled_ppm);
neg_adj = 1;
ppb = -ppb;
}
addend = DEFAULT_ADDEND;
adj = addend;
adj *= ppb;
diff = div_u64(adj, 1000000000ULL);
addend = neg_adj ? addend - diff : addend + diff;
__raw_writel(addend, &regs->addend); __raw_writel(addend, &regs->addend);
...@@ -230,7 +219,7 @@ static const struct ptp_clock_info ptp_ixp_caps = { ...@@ -230,7 +219,7 @@ static const struct ptp_clock_info ptp_ixp_caps = {
.n_ext_ts = N_EXT_TS, .n_ext_ts = N_EXT_TS,
.n_pins = 0, .n_pins = 0,
.pps = 0, .pps = 0,
.adjfreq = ptp_ixp_adjfreq, .adjfine = ptp_ixp_adjfine,
.adjtime = ptp_ixp_adjtime, .adjtime = ptp_ixp_adjtime,
.gettime64 = ptp_ixp_gettime, .gettime64 = ptp_ixp_gettime,
.settime64 = ptp_ixp_settime, .settime64 = ptp_ixp_settime,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment