mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file
@ 2024-08-12  9:47 Csókás, Bence
  2024-08-12  9:47 ` [PATCH v3 net-next 2/2] net: fec: Remove duplicated code Csókás, Bence
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Csókás, Bence @ 2024-08-12  9:47 UTC (permalink / raw)
  To: Jakub Kicinski, Csókás Bence, imx, netdev, linux-kernel
  Cc: Simon Horman, Frank Li, Wei Fang, Shenwei Wang, Clark Wang,
	David S. Miller, Eric Dumazet, Paolo Abeni, Richard Cochran

This function is used in `fec_ptp_enable_pps()` through
struct cyclecounter read(). Moving the declaration makes
it clearer, what's happening.

Fixes: 61d5e2a251fb ("fec: Fix timer capture timing in `fec_ptp_enable_pps()`")
Suggested-by: Frank Li <Frank.li@nxp.com>
Link: https://lore.kernel.org/netdev/20240805144754.2384663-1-csokas.bence@prolan.hu/T/#ma6c21ad264016c24612048b1483769eaff8cdf20
Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
---
 drivers/net/ethernet/freescale/fec_ptp.c | 50 ++++++++++++------------
 1 file changed, 25 insertions(+), 25 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index e32f6724f568..4ed790cb6be4 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -90,6 +90,30 @@
 #define FEC_PTP_MAX_NSEC_PERIOD		4000000000ULL
 #define FEC_PTP_MAX_NSEC_COUNTER	0x80000000ULL
 
+/**
+ * fec_ptp_read - read raw cycle counter (to be used by time counter)
+ * @cc: the cyclecounter structure
+ *
+ * this function reads the cyclecounter registers and is called by the
+ * cyclecounter structure used to construct a ns counter from the
+ * arbitrary fixed point registers
+ */
+static u64 fec_ptp_read(const struct cyclecounter *cc)
+{
+	struct fec_enet_private *fep =
+		container_of(cc, struct fec_enet_private, cc);
+	u32 tempval;
+
+	tempval = readl(fep->hwp + FEC_ATIME_CTRL);
+	tempval |= FEC_T_CTRL_CAPTURE;
+	writel(tempval, fep->hwp + FEC_ATIME_CTRL);
+
+	if (fep->quirks & FEC_QUIRK_BUG_CAPTURE)
+		udelay(1);
+
+	return readl(fep->hwp + FEC_ATIME);
+}
+
 /**
  * fec_ptp_enable_pps
  * @fep: the fec_enet_private structure handle
@@ -136,7 +160,7 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable)
 		 * NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds
 		 * to current timer would be next second.
 		 */
-		tempval = fep->cc.read(&fep->cc);
+		tempval = fec_ptp_read(&fep->cc);
 		/* Convert the ptp local counter to 1588 timestamp */
 		ns = timecounter_cyc2time(&fep->tc, tempval);
 		ts = ns_to_timespec64(ns);
@@ -271,30 +295,6 @@ static enum hrtimer_restart fec_ptp_pps_perout_handler(struct hrtimer *timer)
 	return HRTIMER_NORESTART;
 }
 
-/**
- * fec_ptp_read - read raw cycle counter (to be used by time counter)
- * @cc: the cyclecounter structure
- *
- * this function reads the cyclecounter registers and is called by the
- * cyclecounter structure used to construct a ns counter from the
- * arbitrary fixed point registers
- */
-static u64 fec_ptp_read(const struct cyclecounter *cc)
-{
-	struct fec_enet_private *fep =
-		container_of(cc, struct fec_enet_private, cc);
-	u32 tempval;
-
-	tempval = readl(fep->hwp + FEC_ATIME_CTRL);
-	tempval |= FEC_T_CTRL_CAPTURE;
-	writel(tempval, fep->hwp + FEC_ATIME_CTRL);
-
-	if (fep->quirks & FEC_QUIRK_BUG_CAPTURE)
-		udelay(1);
-
-	return readl(fep->hwp + FEC_ATIME);
-}
-
 /**
  * fec_ptp_start_cyclecounter - create the cycle counter from hw
  * @ndev: network device
-- 
2.34.1



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

* [PATCH v3 net-next 2/2] net: fec: Remove duplicated code
  2024-08-12  9:47 [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file Csókás, Bence
@ 2024-08-12  9:47 ` Csókás, Bence
  2024-08-12 20:58   ` Andrew Lunn
  2024-08-12 20:58 ` [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file Andrew Lunn
  2024-08-14  2:30 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Csókás, Bence @ 2024-08-12  9:47 UTC (permalink / raw)
  To: imx, netdev, linux-kernel
  Cc: Csókás, Bence, Simon Horman, Wei Fang, Shenwei Wang,
	Clark Wang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Richard Cochran

`fec_ptp_pps_perout()` reimplements logic already
in `fec_ptp_read()`. Replace with function call.

Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
---
 drivers/net/ethernet/freescale/fec_ptp.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/freescale/fec_ptp.c b/drivers/net/ethernet/freescale/fec_ptp.c
index 4ed790cb6be4..c97a0e4e7d89 100644
--- a/drivers/net/ethernet/freescale/fec_ptp.c
+++ b/drivers/net/ethernet/freescale/fec_ptp.c
@@ -235,13 +235,7 @@ static int fec_ptp_pps_perout(struct fec_enet_private *fep)
 	timecounter_read(&fep->tc);
 
 	/* Get the current ptp hardware time counter */
-	temp_val = readl(fep->hwp + FEC_ATIME_CTRL);
-	temp_val |= FEC_T_CTRL_CAPTURE;
-	writel(temp_val, fep->hwp + FEC_ATIME_CTRL);
-	if (fep->quirks & FEC_QUIRK_BUG_CAPTURE)
-		udelay(1);
-
-	ptp_hc = readl(fep->hwp + FEC_ATIME);
+	ptp_hc = fec_ptp_read(&fep->cc);
 
 	/* Convert the ptp local counter to 1588 timestamp */
 	curr_time = timecounter_cyc2time(&fep->tc, ptp_hc);
-- 
2.34.1



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

* Re: [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file
  2024-08-12  9:47 [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file Csókás, Bence
  2024-08-12  9:47 ` [PATCH v3 net-next 2/2] net: fec: Remove duplicated code Csókás, Bence
@ 2024-08-12 20:58 ` Andrew Lunn
  2024-08-14  2:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2024-08-12 20:58 UTC (permalink / raw)
  To: Csókás, Bence
  Cc: Jakub Kicinski, imx, netdev, linux-kernel, Simon Horman,
	Frank Li, Wei Fang, Shenwei Wang, Clark Wang, David S. Miller,
	Eric Dumazet, Paolo Abeni, Richard Cochran

On Mon, Aug 12, 2024 at 11:47:13AM +0200, Csókás, Bence wrote:
> This function is used in `fec_ptp_enable_pps()` through
> struct cyclecounter read(). Moving the declaration makes
> it clearer, what's happening.
> 
> Fixes: 61d5e2a251fb ("fec: Fix timer capture timing in `fec_ptp_enable_pps()`")
> Suggested-by: Frank Li <Frank.li@nxp.com>
> Link: https://lore.kernel.org/netdev/20240805144754.2384663-1-csokas.bence@prolan.hu/T/#ma6c21ad264016c24612048b1483769eaff8cdf20
> Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH v3 net-next 2/2] net: fec: Remove duplicated code
  2024-08-12  9:47 ` [PATCH v3 net-next 2/2] net: fec: Remove duplicated code Csókás, Bence
@ 2024-08-12 20:58   ` Andrew Lunn
  0 siblings, 0 replies; 5+ messages in thread
From: Andrew Lunn @ 2024-08-12 20:58 UTC (permalink / raw)
  To: Csókás, Bence
  Cc: imx, netdev, linux-kernel, Simon Horman, Wei Fang, Shenwei Wang,
	Clark Wang, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Richard Cochran

On Mon, Aug 12, 2024 at 11:47:15AM +0200, Csókás, Bence wrote:
> `fec_ptp_pps_perout()` reimplements logic already
> in `fec_ptp_read()`. Replace with function call.
> 
> Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

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

* Re: [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file
  2024-08-12  9:47 [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file Csókás, Bence
  2024-08-12  9:47 ` [PATCH v3 net-next 2/2] net: fec: Remove duplicated code Csókás, Bence
  2024-08-12 20:58 ` [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file Andrew Lunn
@ 2024-08-14  2:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-08-14  2:30 UTC (permalink / raw)
  To: =?utf-8?b?Q3PDs2vDoXMsIEJlbmNlIDxjc29rYXMuYmVuY2VAcHJvbGFuLmh1Pg==?=
  Cc: kuba, imx, netdev, linux-kernel, horms, Frank.li, wei.fang,
	shenwei.wang, xiaoning.wang, davem, edumazet, pabeni,
	richardcochran

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Mon, 12 Aug 2024 11:47:13 +0200 you wrote:
> This function is used in `fec_ptp_enable_pps()` through
> struct cyclecounter read(). Moving the declaration makes
> it clearer, what's happening.
> 
> Fixes: 61d5e2a251fb ("fec: Fix timer capture timing in `fec_ptp_enable_pps()`")
> Suggested-by: Frank Li <Frank.li@nxp.com>
> Link: https://lore.kernel.org/netdev/20240805144754.2384663-1-csokas.bence@prolan.hu/T/#ma6c21ad264016c24612048b1483769eaff8cdf20
> Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu>
> 
> [...]

Here is the summary with links:
  - [v3,net-next,1/2] net: fec: Move `fec_ptp_read()` to the top of the file
    https://git.kernel.org/netdev/net-next/c/4374a1fe580a
  - [v3,net-next,2/2] net: fec: Remove duplicated code
    https://git.kernel.org/netdev/net-next/c/713ebaed68d8

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-08-14  2:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-12  9:47 [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file Csókás, Bence
2024-08-12  9:47 ` [PATCH v3 net-next 2/2] net: fec: Remove duplicated code Csókás, Bence
2024-08-12 20:58   ` Andrew Lunn
2024-08-12 20:58 ` [PATCH v3 net-next 1/2] net: fec: Move `fec_ptp_read()` to the top of the file Andrew Lunn
2024-08-14  2:30 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®