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

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>

authored by

Jacob Keller and committed by
David S. Miller
2e77eded 3b738db5

+4 -15
+4 -15
drivers/ptp/ptp_pch.c
··· 336 336 * PTP clock operations 337 337 */ 338 338 339 - static int ptp_pch_adjfreq(struct ptp_clock_info *ptp, s32 ppb) 339 + static int ptp_pch_adjfine(struct ptp_clock_info *ptp, long scaled_ppm) 340 340 { 341 - u64 adj; 342 - u32 diff, addend; 343 - int neg_adj = 0; 341 + u32 addend; 344 342 struct pch_dev *pch_dev = container_of(ptp, struct pch_dev, caps); 345 343 struct pch_ts_regs __iomem *regs = pch_dev->regs; 346 344 347 - if (ppb < 0) { 348 - neg_adj = 1; 349 - ppb = -ppb; 350 - } 351 - addend = DEFAULT_ADDEND; 352 - adj = addend; 353 - adj *= ppb; 354 - diff = div_u64(adj, 1000000000ULL); 355 - 356 - addend = neg_adj ? addend - diff : addend + diff; 345 + addend = adjust_by_scaled_ppm(DEFAULT_ADDEND, scaled_ppm); 357 346 358 347 iowrite32(addend, &regs->addend); 359 348 ··· 429 440 .n_ext_ts = N_EXT_TS, 430 441 .n_pins = 0, 431 442 .pps = 0, 432 - .adjfreq = ptp_pch_adjfreq, 443 + .adjfine = ptp_pch_adjfine, 433 444 .adjtime = ptp_pch_adjtime, 434 445 .gettime64 = ptp_pch_gettime, 435 446 .settime64 = ptp_pch_settime,