aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Cochran <richardcochran@gmail.com>2015-03-29 17:12:02 -0400
committerDavid S. Miller <davem@davemloft.net>2015-03-31 12:01:17 -0400
commit6f7a9b8ab327a2aa9ee5a6d1670439ce5ed47554 (patch)
tree64fc7c752cb8db4e8fa6628628cf9050f94b31fe
parent843293e1bb7d8cccc3b4a528db9eef710113fb6a (diff)
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>
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_ptp.c26
1 files changed, 13 insertions, 13 deletions
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ptp.c b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
index fabcfa1b45b2..a92b7725dec3 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ptp.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ptp.c
@@ -57,7 +57,7 @@
57 * timespec. However, since the registers are 64 bits of nanoseconds, we must 57 * timespec. However, since the registers are 64 bits of nanoseconds, we must
58 * convert the result to a timespec before we can return. 58 * convert the result to a timespec before we can return.
59 **/ 59 **/
60static void i40e_ptp_read(struct i40e_pf *pf, struct timespec *ts) 60static void i40e_ptp_read(struct i40e_pf *pf, struct timespec64 *ts)
61{ 61{
62 struct i40e_hw *hw = &pf->hw; 62 struct i40e_hw *hw = &pf->hw;
63 u32 hi, lo; 63 u32 hi, lo;
@@ -69,7 +69,7 @@ static void i40e_ptp_read(struct i40e_pf *pf, struct timespec *ts)
69 69
70 ns = (((u64)hi) << 32) | lo; 70 ns = (((u64)hi) << 32) | lo;
71 71
72 *ts = ns_to_timespec(ns); 72 *ts = ns_to_timespec64(ns);
73} 73}
74 74
75/** 75/**
@@ -81,10 +81,10 @@ static void i40e_ptp_read(struct i40e_pf *pf, struct timespec *ts)
81 * we receive a timespec from the stack, we must convert that timespec into 81 * we receive a timespec from the stack, we must convert that timespec into
82 * nanoseconds before programming the registers. 82 * nanoseconds before programming the registers.
83 **/ 83 **/
84static void i40e_ptp_write(struct i40e_pf *pf, const struct timespec *ts) 84static void i40e_ptp_write(struct i40e_pf *pf, const struct timespec64 *ts)
85{ 85{
86 struct i40e_hw *hw = &pf->hw; 86 struct i40e_hw *hw = &pf->hw;
87 u64 ns = timespec_to_ns(ts); 87 u64 ns = timespec64_to_ns(ts);
88 88
89 /* The timer will not update until the high register is written, so 89 /* The timer will not update until the high register is written, so
90 * write the low register first. 90 * write the low register first.
@@ -159,14 +159,14 @@ static int i40e_ptp_adjfreq(struct ptp_clock_info *ptp, s32 ppb)
159static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta) 159static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
160{ 160{
161 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); 161 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
162 struct timespec now, then = ns_to_timespec(delta); 162 struct timespec64 now, then = ns_to_timespec64(delta);
163 unsigned long flags; 163 unsigned long flags;
164 164
165 spin_lock_irqsave(&pf->tmreg_lock, flags); 165 spin_lock_irqsave(&pf->tmreg_lock, flags);
166 166
167 i40e_ptp_read(pf, &now); 167 i40e_ptp_read(pf, &now);
168 now = timespec_add(now, then); 168 now = timespec64_add(now, then);
169 i40e_ptp_write(pf, (const struct timespec *)&now); 169 i40e_ptp_write(pf, (const struct timespec64 *)&now);
170 170
171 spin_unlock_irqrestore(&pf->tmreg_lock, flags); 171 spin_unlock_irqrestore(&pf->tmreg_lock, flags);
172 172
@@ -181,7 +181,7 @@ static int i40e_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
181 * Read the device clock and return the correct value on ns, after converting it 181 * Read the device clock and return the correct value on ns, after converting it
182 * into a timespec struct. 182 * into a timespec struct.
183 **/ 183 **/
184static int i40e_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts) 184static int i40e_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
185{ 185{
186 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); 186 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
187 unsigned long flags; 187 unsigned long flags;
@@ -202,7 +202,7 @@ static int i40e_ptp_gettime(struct ptp_clock_info *ptp, struct timespec *ts)
202 * to ns happens in the write function. 202 * to ns happens in the write function.
203 **/ 203 **/
204static int i40e_ptp_settime(struct ptp_clock_info *ptp, 204static int i40e_ptp_settime(struct ptp_clock_info *ptp,
205 const struct timespec *ts) 205 const struct timespec64 *ts)
206{ 206{
207 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps); 207 struct i40e_pf *pf = container_of(ptp, struct i40e_pf, ptp_caps);
208 unsigned long flags; 208 unsigned long flags;
@@ -613,8 +613,8 @@ static long i40e_ptp_create_clock(struct i40e_pf *pf)
613 pf->ptp_caps.pps = 0; 613 pf->ptp_caps.pps = 0;
614 pf->ptp_caps.adjfreq = i40e_ptp_adjfreq; 614 pf->ptp_caps.adjfreq = i40e_ptp_adjfreq;
615 pf->ptp_caps.adjtime = i40e_ptp_adjtime; 615 pf->ptp_caps.adjtime = i40e_ptp_adjtime;
616 pf->ptp_caps.gettime = i40e_ptp_gettime; 616 pf->ptp_caps.gettime64 = i40e_ptp_gettime;
617 pf->ptp_caps.settime = i40e_ptp_settime; 617 pf->ptp_caps.settime64 = i40e_ptp_settime;
618 pf->ptp_caps.enable = i40e_ptp_feature_enable; 618 pf->ptp_caps.enable = i40e_ptp_feature_enable;
619 619
620 /* Attempt to register the clock before enabling the hardware. */ 620 /* Attempt to register the clock before enabling the hardware. */
@@ -673,7 +673,7 @@ void i40e_ptp_init(struct i40e_pf *pf)
673 dev_err(&pf->pdev->dev, "%s: ptp_clock_register failed\n", 673 dev_err(&pf->pdev->dev, "%s: ptp_clock_register failed\n",
674 __func__); 674 __func__);
675 } else { 675 } else {
676 struct timespec ts; 676 struct timespec64 ts;
677 u32 regval; 677 u32 regval;
678 678
679 dev_info(&pf->pdev->dev, "%s: added PHC on %s\n", __func__, 679 dev_info(&pf->pdev->dev, "%s: added PHC on %s\n", __func__,
@@ -695,7 +695,7 @@ void i40e_ptp_init(struct i40e_pf *pf)
695 i40e_ptp_set_timestamp_mode(pf, &pf->tstamp_config); 695 i40e_ptp_set_timestamp_mode(pf, &pf->tstamp_config);
696 696
697 /* Set the clock value. */ 697 /* Set the clock value. */
698 ts = ktime_to_timespec(ktime_get_real()); 698 ts = ktime_to_timespec64(ktime_get_real());
699 i40e_ptp_settime(&pf->ptp_caps, &ts); 699 i40e_ptp_settime(&pf->ptp_caps, &ts);
700 } 700 }
701} 701}