Commit 337ffae0 authored by Jacob Keller's avatar Jacob Keller Committed by David S. Miller

ptp: xgbe: convert to .adjfine and adjust_by_scaled_ppm

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

Convert this driver to .adjfine and use adjust_by_scaled_ppm to calculate
the new addend value.
Signed-off-by: default avatarJacob Keller <jacob.e.keller@intel.com>
Acked-by: default avatarRichard Cochran <richardcochran@gmail.com>
Acked-by: default avatarTom Lendacky <thomas.lendacky@amd.com>
Cc: Shyam Sundar S K <Shyam-sundar.S-k@amd.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 673dd2c7
...@@ -134,27 +134,15 @@ static u64 xgbe_cc_read(const struct cyclecounter *cc) ...@@ -134,27 +134,15 @@ static u64 xgbe_cc_read(const struct cyclecounter *cc)
return nsec; return nsec;
} }
static int xgbe_adjfreq(struct ptp_clock_info *info, s32 delta) static int xgbe_adjfine(struct ptp_clock_info *info, long scaled_ppm)
{ {
struct xgbe_prv_data *pdata = container_of(info, struct xgbe_prv_data *pdata = container_of(info,
struct xgbe_prv_data, struct xgbe_prv_data,
ptp_clock_info); ptp_clock_info);
unsigned long flags; unsigned long flags;
u64 adjust; u64 addend;
u32 addend, diff;
unsigned int neg_adjust = 0;
if (delta < 0) { addend = adjust_by_scaled_ppm(pdata->tstamp_addend, scaled_ppm);
neg_adjust = 1;
delta = -delta;
}
adjust = pdata->tstamp_addend;
adjust *= delta;
diff = div_u64(adjust, 1000000000UL);
addend = (neg_adjust) ? pdata->tstamp_addend - diff :
pdata->tstamp_addend + diff;
spin_lock_irqsave(&pdata->tstamp_lock, flags); spin_lock_irqsave(&pdata->tstamp_lock, flags);
...@@ -235,7 +223,7 @@ void xgbe_ptp_register(struct xgbe_prv_data *pdata) ...@@ -235,7 +223,7 @@ void xgbe_ptp_register(struct xgbe_prv_data *pdata)
netdev_name(pdata->netdev)); netdev_name(pdata->netdev));
info->owner = THIS_MODULE; info->owner = THIS_MODULE;
info->max_adj = pdata->ptpclk_rate; info->max_adj = pdata->ptpclk_rate;
info->adjfreq = xgbe_adjfreq; info->adjfine = xgbe_adjfine;
info->adjtime = xgbe_adjtime; info->adjtime = xgbe_adjtime;
info->gettime64 = xgbe_gettime; info->gettime64 = xgbe_gettime;
info->settime64 = xgbe_settime; info->settime64 = xgbe_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