linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse
@ 2015-03-31 21:08 Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 01/11] ptp: blackfin: use helpers for converting ns to timespec Richard Cochran
                   ` (12 more replies)
  0 siblings, 13 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch series is a follow up to the recent timespec64 work for the
PTP Hardware Clock drivers.  Arnd noticed that drivers are using open
coded implementations of ns_to_timespec64 and timespec64_to_ns.  This
series replaces the open coded logic with the helper functions.

Thanks,
Richard

Richard Cochran (11):
  ptp: blackfin: use helpers for converting ns to timespec.
  ptp: bnx2x: use helpers for converting ns to timespec.
  ptp: tg3: use helpers for converting ns to timespec.
  ptp: fec: use helpers for converting ns to timespec.
  ptp: gianfar: use helpers for converting ns to timespec.
  ptp: e1000e: use helpers for converting ns to timespec.
  ptp: igb: use helpers for converting ns to timespec.
  ptp: ixgbe: use helpers for converting ns to timespec.
  ptp: mlx4: use helpers for converting ns to timespec.
  ptp: stmmac: use helpers for converting ns to timespec.
  ptp: cpts: use helpers for converting ns to timespec.

 drivers/net/ethernet/adi/bfin_mac.c              |    8 +++-----
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |    7 ++-----
 drivers/net/ethernet/broadcom/tg3.c              |    4 +---
 drivers/net/ethernet/freescale/fec_ptp.c         |    7 ++-----
 drivers/net/ethernet/freescale/gianfar_ptp.c     |    8 +++-----
 drivers/net/ethernet/intel/e1000e/ptp.c          |    4 +---
 drivers/net/ethernet/intel/igb/igb_ptp.c         |    7 ++-----
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c     |    7 ++-----
 drivers/net/ethernet/mellanox/mlx4/en_clock.c    |    4 +---
 drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c |    4 +---
 drivers/net/ethernet/ti/cpts.c                   |    7 ++-----
 11 files changed, 20 insertions(+), 47 deletions(-)

-- 
1.7.10.4


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH net-next 01/11] ptp: blackfin: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 02/11] ptp: bnx2x: " Richard Cochran
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() and
timespec64_to_ns() instead of open coding the same logic.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/adi/bfin_mac.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/adi/bfin_mac.c b/drivers/net/ethernet/adi/bfin_mac.c
index 0c37aef..096531a 100644
--- a/drivers/net/ethernet/adi/bfin_mac.c
+++ b/drivers/net/ethernet/adi/bfin_mac.c
@@ -986,7 +986,6 @@ static int bfin_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 static int bfin_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
 	u64 ns;
-	u32 remainder;
 	unsigned long flags;
 	struct bfin_mac_local *lp =
 		container_of(ptp, struct bfin_mac_local, caps);
@@ -997,8 +996,8 @@ static int bfin_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 
 	spin_unlock_irqrestore(&lp->phc_lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
+
 	return 0;
 }
 
@@ -1010,8 +1009,7 @@ static int bfin_ptp_settime(struct ptp_clock_info *ptp,
 	struct bfin_mac_local *lp =
 		container_of(ptp, struct bfin_mac_local, caps);
 
-	ns = ts->tv_sec * 1000000000ULL;
-	ns += ts->tv_nsec;
+	ns = timespec64_to_ns(ts);
 
 	spin_lock_irqsave(&lp->phc_lock, flags);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 02/11] ptp: bnx2x: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 01/11] ptp: blackfin: use helpers for converting ns to timespec Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 03/11] ptp: tg3: " Richard Cochran
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() and
timespec64_to_ns() instead of open coding the same logic.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 765667c..1925296 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -13282,14 +13282,12 @@ static int bnx2x_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
 	struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
 	u64 ns;
-	u32 remainder;
 
 	ns = timecounter_read(&bp->timecounter);
 
 	DP(BNX2X_MSG_PTP, "PTP gettime called, ns = %llu\n", ns);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
 
 	return 0;
 }
@@ -13300,8 +13298,7 @@ static int bnx2x_ptp_settime(struct ptp_clock_info *ptp,
 	struct bnx2x *bp = container_of(ptp, struct bnx2x, ptp_clock_info);
 	u64 ns;
 
-	ns = ts->tv_sec * 1000000000ULL;
-	ns += ts->tv_nsec;
+	ns = timespec64_to_ns(ts);
 
 	DP(BNX2X_MSG_PTP, "PTP settime called, ns = %llu\n", ns);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 03/11] ptp: tg3: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 01/11] ptp: blackfin: use helpers for converting ns to timespec Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 02/11] ptp: bnx2x: " Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 04/11] ptp: fec: " Richard Cochran
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() instead of
open coding the same logic.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/broadcom/tg3.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index d02d19b..1270b18 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -6220,7 +6220,6 @@ static int tg3_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 static int tg3_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
 	u64 ns;
-	u32 remainder;
 	struct tg3 *tp = container_of(ptp, struct tg3, ptp_info);
 
 	tg3_full_lock(tp, 0);
@@ -6228,8 +6227,7 @@ static int tg3_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 	ns += tp->ptp_adjust;
 	tg3_full_unlock(tp);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
 
 	return 0;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 04/11] ptp: fec: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (2 preceding siblings ...)
  2015-03-31 21:08 ` [PATCH net-next 03/11] ptp: tg3: " Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 05/11] ptp: gianfar: " Richard Cochran
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() and
timespec64_to_ns() instead of open coding the same logic.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/freescale/fec_ptp.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index b833993..a583d89 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -395,15 +395,13 @@ static int fec_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 	struct fec_enet_private *adapter =
 	    container_of(ptp, struct fec_enet_private, ptp_caps);
 	u64 ns;
-	u32 remainder;
 	unsigned long flags;
 
 	spin_lock_irqsave(&adapter->tmreg_lock, flags);
 	ns = timecounter_read(&adapter->tc);
 	spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
 
 	return 0;
 }
@@ -433,8 +431,7 @@ static int fec_ptp_settime(struct ptp_clock_info *ptp,
 		return -EINVAL;
 	}
 
-	ns = ts->tv_sec * 1000000000ULL;
-	ns += ts->tv_nsec;
+	ns = timespec64_to_ns(ts);
 	/* Get the timer value based on timestamp.
 	 * Update the counter with the masked value.
 	 */
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 05/11] ptp: gianfar: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (3 preceding siblings ...)
  2015-03-31 21:08 ` [PATCH net-next 04/11] ptp: fec: " Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 06/11] ptp: e1000e: " Richard Cochran
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() and
timespec64_to_ns() instead of open coding the same logic.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/freescale/gianfar_ptp.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar_ptp.c b/drivers/net/ethernet/freescale/gianfar_ptp.c
index 04265a7..8e3cd77 100644
--- a/drivers/net/ethernet/freescale/gianfar_ptp.c
+++ b/drivers/net/ethernet/freescale/gianfar_ptp.c
@@ -326,7 +326,6 @@ static int ptp_gianfar_gettime(struct ptp_clock_info *ptp,
 			       struct timespec64 *ts)
 {
 	u64 ns;
-	u32 remainder;
 	unsigned long flags;
 	struct etsects *etsects = container_of(ptp, struct etsects, caps);
 
@@ -336,8 +335,8 @@ static int ptp_gianfar_gettime(struct ptp_clock_info *ptp,
 
 	spin_unlock_irqrestore(&etsects->lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
+
 	return 0;
 }
 
@@ -348,8 +347,7 @@ static int ptp_gianfar_settime(struct ptp_clock_info *ptp,
 	unsigned long flags;
 	struct etsects *etsects = container_of(ptp, struct etsects, caps);
 
-	ns = ts->tv_sec * 1000000000ULL;
-	ns += ts->tv_nsec;
+	ns = timespec64_to_ns(ts);
 
 	spin_lock_irqsave(&etsects->lock, flags);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 06/11] ptp: e1000e: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (4 preceding siblings ...)
  2015-03-31 21:08 ` [PATCH net-next 05/11] ptp: gianfar: " Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:10   ` Keller, Jacob E
  2015-03-31 21:08 ` [PATCH net-next 07/11] ptp: igb: " Richard Cochran
                   ` (6 subsequent siblings)
  12 siblings, 1 reply; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() instead of
open coding the same logic.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/intel/e1000e/ptp.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c
index b747a3e..d2272ad 100644
--- a/drivers/net/ethernet/intel/e1000e/ptp.c
+++ b/drivers/net/ethernet/intel/e1000e/ptp.c
@@ -111,15 +111,13 @@ static int e1000e_phc_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 	struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter,
 						     ptp_clock_info);
 	unsigned long flags;
-	u32 remainder;
 	u64 ns;
 
 	spin_lock_irqsave(&adapter->systim_lock, flags);
 	ns = timecounter_read(&adapter->tc);
 	spin_unlock_irqrestore(&adapter->systim_lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, NSEC_PER_SEC, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
 
 	return 0;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 07/11] ptp: igb: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (5 preceding siblings ...)
  2015-03-31 21:08 ` [PATCH net-next 06/11] ptp: e1000e: " Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 08/11] ptp: ixgbe: " Richard Cochran
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() and
timespec64_to_ns() instead of open coding the same logic.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/intel/igb/igb_ptp.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/igb/igb_ptp.c b/drivers/net/ethernet/intel/igb/igb_ptp.c
index 0348b7e..b3b60a8 100644
--- a/drivers/net/ethernet/intel/igb/igb_ptp.c
+++ b/drivers/net/ethernet/intel/igb/igb_ptp.c
@@ -290,7 +290,6 @@ static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp,
 					       ptp_caps);
 	unsigned long flags;
 	u64 ns;
-	u32 remainder;
 
 	spin_lock_irqsave(&igb->tmreg_lock, flags);
 
@@ -298,8 +297,7 @@ static int igb_ptp_gettime_82576(struct ptp_clock_info *ptp,
 
 	spin_unlock_irqrestore(&igb->tmreg_lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
 
 	return 0;
 }
@@ -328,8 +326,7 @@ static int igb_ptp_settime_82576(struct ptp_clock_info *ptp,
 	unsigned long flags;
 	u64 ns;
 
-	ns = ts->tv_sec * 1000000000ULL;
-	ns += ts->tv_nsec;
+	ns = timespec64_to_ns(ts);
 
 	spin_lock_irqsave(&igb->tmreg_lock, flags);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 08/11] ptp: ixgbe: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (6 preceding siblings ...)
  2015-03-31 21:08 ` [PATCH net-next 07/11] ptp: igb: " Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 09/11] ptp: mlx4: " Richard Cochran
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() and
timespec64_to_ns() instead of open coding the same logic.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
index 75b9e93..e5ba040 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c
@@ -284,15 +284,13 @@ static int ixgbe_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 	struct ixgbe_adapter *adapter =
 		container_of(ptp, struct ixgbe_adapter, ptp_caps);
 	u64 ns;
-	u32 remainder;
 	unsigned long flags;
 
 	spin_lock_irqsave(&adapter->tmreg_lock, flags);
 	ns = timecounter_read(&adapter->tc);
 	spin_unlock_irqrestore(&adapter->tmreg_lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
 
 	return 0;
 }
@@ -313,8 +311,7 @@ static int ixgbe_ptp_settime(struct ptp_clock_info *ptp,
 	u64 ns;
 	unsigned long flags;
 
-	ns = ts->tv_sec * 1000000000ULL;
-	ns += ts->tv_nsec;
+	ns = timespec64_to_ns(ts);
 
 	/* reset the timecounter */
 	spin_lock_irqsave(&adapter->tmreg_lock, flags);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 09/11] ptp: mlx4: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (7 preceding siblings ...)
  2015-03-31 21:08 ` [PATCH net-next 08/11] ptp: ixgbe: " Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 10/11] ptp: stmmac: " Richard Cochran
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() instead of
open coding the same logic.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/mellanox/mlx4/en_clock.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx4/en_clock.c b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
index 666e7bd..8a083d7 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_clock.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_clock.c
@@ -170,15 +170,13 @@ static int mlx4_en_phc_gettime(struct ptp_clock_info *ptp,
 	struct mlx4_en_dev *mdev = container_of(ptp, struct mlx4_en_dev,
 						ptp_clock_info);
 	unsigned long flags;
-	u32 remainder;
 	u64 ns;
 
 	write_lock_irqsave(&mdev->clock_lock, flags);
 	ns = timecounter_read(&mdev->clock);
 	write_unlock_irqrestore(&mdev->clock_lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, NSEC_PER_SEC, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
 
 	return 0;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 10/11] ptp: stmmac: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (8 preceding siblings ...)
  2015-03-31 21:08 ` [PATCH net-next 09/11] ptp: mlx4: " Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:08 ` [PATCH net-next 11/11] ptp: cpts: " Richard Cochran
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() instead of
open coding the same logic.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
index 172f318..170a18b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
@@ -111,7 +111,6 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts)
 	    container_of(ptp, struct stmmac_priv, ptp_clock_ops);
 	unsigned long flags;
 	u64 ns;
-	u32 reminder;
 
 	spin_lock_irqsave(&priv->ptp_lock, flags);
 
@@ -119,8 +118,7 @@ static int stmmac_get_time(struct ptp_clock_info *ptp, struct timespec64 *ts)
 
 	spin_unlock_irqrestore(&priv->ptp_lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000ULL, &reminder);
-	ts->tv_nsec = reminder;
+	*ts = ns_to_timespec64(ns);
 
 	return 0;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH net-next 11/11] ptp: cpts: use helpers for converting ns to timespec.
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (9 preceding siblings ...)
  2015-03-31 21:08 ` [PATCH net-next 10/11] ptp: stmmac: " Richard Cochran
@ 2015-03-31 21:08 ` Richard Cochran
  2015-03-31 21:11 ` [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Keller, Jacob E
  2015-03-31 21:19 ` David Miller
  12 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:08 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Amir Vadai, Arnd Bergmann, Baolin Wang,
	David Miller, Frank Li, Giuseppe Cavallaro, Jacob Keller,
	Jeff Kirsher, John Stultz, Luwei Zhou, Matthew Vick,
	Michael Chan, Prashant Sreedharan, Rayagond K, Sonic Zhang,
	Sony Chacko, Thomas Gleixner

This patch changes the driver to use ns_to_timespec64() and
timespec64_to_ns() instead of open coding the same logic.

Compile tested only.

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/ethernet/ti/cpts.c |    7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpts.c b/drivers/net/ethernet/ti/cpts.c
index 074b636..85a55b4 100644
--- a/drivers/net/ethernet/ti/cpts.c
+++ b/drivers/net/ethernet/ti/cpts.c
@@ -170,7 +170,6 @@ static int cpts_ptp_adjtime(struct ptp_clock_info *ptp, s64 delta)
 static int cpts_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 {
 	u64 ns;
-	u32 remainder;
 	unsigned long flags;
 	struct cpts *cpts = container_of(ptp, struct cpts, info);
 
@@ -178,8 +177,7 @@ static int cpts_ptp_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
 	ns = timecounter_read(&cpts->tc);
 	spin_unlock_irqrestore(&cpts->lock, flags);
 
-	ts->tv_sec = div_u64_rem(ns, 1000000000, &remainder);
-	ts->tv_nsec = remainder;
+	*ts = ns_to_timespec64(ns);
 
 	return 0;
 }
@@ -191,8 +189,7 @@ static int cpts_ptp_settime(struct ptp_clock_info *ptp,
 	unsigned long flags;
 	struct cpts *cpts = container_of(ptp, struct cpts, info);
 
-	ns = ts->tv_sec * 1000000000ULL;
-	ns += ts->tv_nsec;
+	ns = timespec64_to_ns(ts);
 
 	spin_lock_irqsave(&cpts->lock, flags);
 	timecounter_init(&cpts->tc, &cpts->cc, ns);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next 06/11] ptp: e1000e: use helpers for converting ns to timespec.
  2015-03-31 21:08 ` [PATCH net-next 06/11] ptp: e1000e: " Richard Cochran
@ 2015-03-31 21:10   ` Keller, Jacob E
  0 siblings, 0 replies; 16+ messages in thread
From: Keller, Jacob E @ 2015-03-31 21:10 UTC (permalink / raw)
  To: richardcochran
  Cc: linux-kernel, baolin.wang, b45643, amirv, peppe.cavallaro,
	sonic.zhang, rayagond, tglx, sony.chacko, Vick, Matthew, arnd,
	Frank.Li, netdev, mchan, prashant, davem, Kirsher, Jeffrey T,
	john.stultz

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 1369 bytes --]

On Tue, 2015-03-31 at 23:08 +0200, Richard Cochran wrote:
> This patch changes the driver to use ns_to_timespec64() instead of
> open coding the same logic.
> 
> Compile tested only.
> 
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>
> ---
>  drivers/net/ethernet/intel/e1000e/ptp.c |    4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/e1000e/ptp.c b/drivers/net/ethernet/intel/e1000e/ptp.c
> index b747a3e..d2272ad 100644
> --- a/drivers/net/ethernet/intel/e1000e/ptp.c
> +++ b/drivers/net/ethernet/intel/e1000e/ptp.c
> @@ -111,15 +111,13 @@ static int e1000e_phc_gettime(struct ptp_clock_info *ptp, struct timespec64 *ts)
>  	struct e1000_adapter *adapter = container_of(ptp, struct e1000_adapter,
>  						     ptp_clock_info);
>  	unsigned long flags;
> -	u32 remainder;
>  	u64 ns;
>  
>  	spin_lock_irqsave(&adapter->systim_lock, flags);
>  	ns = timecounter_read(&adapter->tc);
>  	spin_unlock_irqrestore(&adapter->systim_lock, flags);
>  
> -	ts->tv_sec = div_u64_rem(ns, NSEC_PER_SEC, &remainder);
> -	ts->tv_nsec = remainder;
> +	*ts = ns_to_timespec64(ns);
>  
>  	return 0;
>  }


Acked-by: Jacob Keller <jacob.e.keller@intel.com>
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (10 preceding siblings ...)
  2015-03-31 21:08 ` [PATCH net-next 11/11] ptp: cpts: " Richard Cochran
@ 2015-03-31 21:11 ` Keller, Jacob E
  2015-03-31 21:38   ` Richard Cochran
  2015-03-31 21:19 ` David Miller
  12 siblings, 1 reply; 16+ messages in thread
From: Keller, Jacob E @ 2015-03-31 21:11 UTC (permalink / raw)
  To: richardcochran
  Cc: linux-kernel, baolin.wang, b45643, amirv, peppe.cavallaro,
	sonic.zhang, rayagond, tglx, sony.chacko, Vick, Matthew, arnd,
	Frank.Li, netdev, mchan, prashant, davem, Kirsher, Jeffrey T,
	john.stultz

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2121 bytes --]

On Tue, 2015-03-31 at 23:08 +0200, Richard Cochran wrote:
> This patch series is a follow up to the recent timespec64 work for the
> PTP Hardware Clock drivers.  Arnd noticed that drivers are using open
> coded implementations of ns_to_timespec64 and timespec64_to_ns.  This
> series replaces the open coded logic with the helper functions.
> 
> Thanks,
> Richard
> 
> Richard Cochran (11):
>   ptp: blackfin: use helpers for converting ns to timespec.
>   ptp: bnx2x: use helpers for converting ns to timespec.
>   ptp: tg3: use helpers for converting ns to timespec.
>   ptp: fec: use helpers for converting ns to timespec.
>   ptp: gianfar: use helpers for converting ns to timespec.
>   ptp: e1000e: use helpers for converting ns to timespec.
>   ptp: igb: use helpers for converting ns to timespec.
>   ptp: ixgbe: use helpers for converting ns to timespec.
>   ptp: mlx4: use helpers for converting ns to timespec.
>   ptp: stmmac: use helpers for converting ns to timespec.
>   ptp: cpts: use helpers for converting ns to timespec.
> 
>  drivers/net/ethernet/adi/bfin_mac.c              |    8 +++-----
>  drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c |    7 ++-----
>  drivers/net/ethernet/broadcom/tg3.c              |    4 +---
>  drivers/net/ethernet/freescale/fec_ptp.c         |    7 ++-----
>  drivers/net/ethernet/freescale/gianfar_ptp.c     |    8 +++-----
>  drivers/net/ethernet/intel/e1000e/ptp.c          |    4 +---
>  drivers/net/ethernet/intel/igb/igb_ptp.c         |    7 ++-----
>  drivers/net/ethernet/intel/ixgbe/ixgbe_ptp.c     |    7 ++-----
>  drivers/net/ethernet/mellanox/mlx4/en_clock.c    |    4 +---
>  drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c |    4 +---
>  drivers/net/ethernet/ti/cpts.c                   |    7 ++-----
>  11 files changed, 20 insertions(+), 47 deletions(-)
> 

For all the Intel drivers, this looks fine. I'm surprised I never
noticed before.

Acked-by: Jacob Keller <jacob.e.keller@intel.com>
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse
  2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
                   ` (11 preceding siblings ...)
  2015-03-31 21:11 ` [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Keller, Jacob E
@ 2015-03-31 21:19 ` David Miller
  12 siblings, 0 replies; 16+ messages in thread
From: David Miller @ 2015-03-31 21:19 UTC (permalink / raw)
  To: richardcochran
  Cc: netdev, linux-kernel, amirv, arnd, baolin.wang, Frank.Li,
	peppe.cavallaro, jacob.e.keller, jeffrey.t.kirsher, john.stultz,
	b45643, matthew.vick, mchan, prashant, rayagond, sonic.zhang,
	sony.chacko, tglx

From: Richard Cochran <richardcochran@gmail.com>
Date: Tue, 31 Mar 2015 23:08:05 +0200

> This patch series is a follow up to the recent timespec64 work for the
> PTP Hardware Clock drivers.  Arnd noticed that drivers are using open
> coded implementations of ns_to_timespec64 and timespec64_to_ns.  This
> series replaces the open coded logic with the helper functions.

Looks good, series applied, thanks.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse
  2015-03-31 21:11 ` [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Keller, Jacob E
@ 2015-03-31 21:38   ` Richard Cochran
  0 siblings, 0 replies; 16+ messages in thread
From: Richard Cochran @ 2015-03-31 21:38 UTC (permalink / raw)
  To: Keller, Jacob E
  Cc: linux-kernel, baolin.wang, b45643, amirv, peppe.cavallaro,
	sonic.zhang, rayagond, tglx, sony.chacko, Vick, Matthew, arnd,
	Frank.Li, netdev, mchan, prashant, davem, Kirsher, Jeffrey T,
	john.stultz

On Tue, Mar 31, 2015 at 09:11:30PM +0000, Keller, Jacob E wrote:
> For all the Intel drivers, this looks fine. I'm surprised I never
> noticed before.

I think the helpers appeared only after the first PHC drivers.

Thanks,
Richard

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2015-03-31 21:39 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-31 21:08 [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 01/11] ptp: blackfin: use helpers for converting ns to timespec Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 02/11] ptp: bnx2x: " Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 03/11] ptp: tg3: " Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 04/11] ptp: fec: " Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 05/11] ptp: gianfar: " Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 06/11] ptp: e1000e: " Richard Cochran
2015-03-31 21:10   ` Keller, Jacob E
2015-03-31 21:08 ` [PATCH net-next 07/11] ptp: igb: " Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 08/11] ptp: ixgbe: " Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 09/11] ptp: mlx4: " Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 10/11] ptp: stmmac: " Richard Cochran
2015-03-31 21:08 ` [PATCH net-next 11/11] ptp: cpts: " Richard Cochran
2015-03-31 21:11 ` [PATCH net-next 00/11] remove open coded ns_to_timespec64 and reverse Keller, Jacob E
2015-03-31 21:38   ` Richard Cochran
2015-03-31 21:19 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).