Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Jacob 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: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jacob Keller and committed by
David S. Miller
319d77e9 2e77eded

+4 -15
+4 -15
drivers/net/ethernet/xscale/ptp_ixp46x.c
··· 120 120 * PTP clock operations 121 121 */ 122 122 123 - static int ptp_ixp_adjfreq(struct ptp_clock_info *ptp, s32 ppb) 123 + static int ptp_ixp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm) 124 124 { 125 - u64 adj; 126 - u32 diff, addend; 127 - int neg_adj = 0; 125 + u32 addend; 128 126 struct ixp_clock *ixp_clock = container_of(ptp, struct ixp_clock, caps); 129 127 struct ixp46x_ts_regs *regs = ixp_clock->regs; 130 128 131 - if (ppb < 0) { 132 - neg_adj = 1; 133 - ppb = -ppb; 134 - } 135 - addend = DEFAULT_ADDEND; 136 - adj = addend; 137 - adj *= ppb; 138 - diff = div_u64(adj, 1000000000ULL); 139 - 140 - addend = neg_adj ? addend - diff : addend + diff; 129 + addend = adjust_by_scaled_ppm(DEFAULT_ADDEND, scaled_ppm); 141 130 142 131 __raw_writel(addend, &regs->addend); 143 132 ··· 219 230 .n_ext_ts = N_EXT_TS, 220 231 .n_pins = 0, 221 232 .pps = 0, 222 - .adjfreq = ptp_ixp_adjfreq, 233 + .adjfine = ptp_ixp_adjfine, 223 234 .adjtime = ptp_ixp_adjtime, 224 235 .gettime64 = ptp_ixp_gettime, 225 236 .settime64 = ptp_ixp_settime,