ptp: i40e: convert to the 64 bit get/set time methods.

The device appears to use a 64 bit nanoseconds register, and so with
this patch the driver should be ready for the year 2038.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
Acked-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Richard Cochran 2015-03-29 23:12:02 +02:00 committed by David S. Miller
parent 843293e1bb
commit 6f7a9b8ab3
1 changed files with 13 additions and 13 deletions

View File

@ -57,7 +57,7 @@
* timespec. However, since the registers are 64 bits of nanoseconds, we must * timespec. However, since the registers are 64 bits of nanoseconds, we must
* convert the result to a timespec before we can return. * convert the result to a timespec before we can return.
**/ **/
static void i40e_ptp_read(struct i40e_pf *pf, struct timespec *ts) static void i40e_ptp_read(struct i40e_pf *pf, struct timespec64 *ts)
{ {
struct i40e_hw *hw = &pf->hw; struct i40e_hw *hw = &pf->hw;
u32 hi, lo; u32 hi, lo;
@ -69,7 +69,7 @@ static void i40e_ptp_read(struct i40e_pf *pf, struct timespec *ts)
ns = (((u64)hi) << 32) | lo; ns = (((u64)hi) << 32) | lo;
*ts = ns_to_timespec(ns); *ts = ns_to_timespec64(ns);
} }
/** /**
@ -81,10 +81,10 @@ static void i40e_ptp_read(struct i40e_pf *pf, struct timespec *ts)
* we receive a timespec from the stack, we must convert that timespec into * we receive a timespec from the stack, we must convert that timespec into
* nanoseconds before programming the registers. * nanoseconds before programming the registers.
**/ **/
static void i40e_ptp_write(struct i40e_pf *pf, const struct timespec *ts) static void i40e_ptp_write(struct i40e_pf *pf, const struct timespec64 *ts)
{ {
struct i40e_hw *hw = &pf->hw; struct i40e_hw *hw = &pf->hw;
u64 ns = timespec_to_ns(ts); u64 ns = timespec64_to_ns(ts);
/* The timer will not update until the high register is written, so /* The timer will not update until the high register is written, so
* write the low register first. * write the low register first.
@ -159,14 +159,14 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
{ {
struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
struct timespec now, then = ns_to_timespec(delta); struct timespec64 now, then = ns_to_timespec64(delta);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&pf->tmreg_lock, flags); spin_lock_irqsave(&pf->tmreg_lock, flags);
i40e_ptp_read(pf, &now); i40e_ptp_read(pf, &now);
now = timespec_add(now, then); now = timespec64_add(now, then);
i40e_ptp_write(pf, (const struct timespec *)&now); i40e_ptp_write(pf, (const struct timespec64 *)&now);
spin_unlock_irqrestore(&pf->tmreg_lock, flags); spin_unlock_irqrestore(&pf->tmreg_lock, flags);
@ -181,7 +181,7 @@ static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
* Read the device clock and return the correct value on ns, after converting it * Read the device clock and return the correct value on ns, after converting it
* into a timespec struct. * into a timespec struct.
**/ **/
static int i40e_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts) static int i40e_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
{ {
struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
unsigned long flags; unsigned long flags;
@ -202,7 +202,7 @@ static int i40e_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
* to ns happens in the write function. * to ns happens in the write function.
**/ **/
static int i40e_ptp_settime(struct ptp_clock_info *ptp, static int i40e_ptp_settime(struct ptp_clock_info *ptp,
const struct timespec *ts) const struct timespec64 *ts)
{ {
struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
unsigned long flags; unsigned long flags;
@ -613,8 +613,8 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf)
pf->ptp_caps.pps = 0; pf->ptp_caps.pps = 0;
pf->ptp_caps.adjfreq = i40e_ptp_adjfreq; pf->ptp_caps.adjfreq = i40e_ptp_adjfreq;
pf->ptp_caps.adjtime = i40e_ptp_adjtime; pf->ptp_caps.adjtime = i40e_ptp_adjtime;
pf->ptp_caps.gettime = i40e_ptp_gettime; pf->ptp_caps.gettime64 = i40e_ptp_gettime;
pf->ptp_caps.settime = i40e_ptp_settime; pf->ptp_caps.settime64 = i40e_ptp_settime;
pf->ptp_caps.enable = i40e_ptp_feature_enable; pf->ptp_caps.enable = i40e_ptp_feature_enable;
/* Attempt to register the clock before enabling the hardware. */ /* Attempt to register the clock before enabling the hardware. */
@ -673,7 +673,7 @@ void i40e_ptp_init(struct i40e_pf *pf)
dev_err(&pf->pdev->dev, "%s: ptp_clock_register failed\n", dev_err(&pf->pdev->dev, "%s: ptp_clock_register failed\n",
__func__); __func__);
} else { } else {
struct timespec ts; struct timespec64 ts;
u32 regval; u32 regval;
dev_info(&pf->pdev->dev, "%s: added PHC on %s\n", __func__, dev_info(&pf->pdev->dev, "%s: added PHC on %s\n", __func__,
@ -695,7 +695,7 @@ void i40e_ptp_init(struct i40e_pf *pf)
i40e_ptp_set_timestamp_mode(pf, &pf->tstamp_config); i40e_ptp_set_timestamp_mode(pf, &pf->tstamp_config);
/* Set the clock value. */ /* Set the clock value. */
ts = ktime_to_timespec(ktime_get_real()); ts = ktime_to_timespec64(ktime_get_real());
i40e_ptp_settime(&pf->ptp_caps, &ts); i40e_ptp_settime(&pf->ptp_caps, &ts);
} }
} }