Skip to content

Commit bc40071

Browse files
Csókás, Bencemehmetb0
Csókás, Bence
authored andcommitted
net: fec: Move fec_ptp_read() to the top of the file
BugLink: https://bugs.launchpad.net/bugs/2097393 commit 4374a1fe580a14f6152752390c678d90311df247 upstream. This function is used in `fec_ptp_enable_pps()` through struct cyclecounter read(). Moving the declaration makes it clearer, what's happening. Suggested-by: Frank Li <[email protected]> Link: https://lore.kernel.org/netdev/[email protected]/T/#ma6c21ad264016c24612048b1483769eaff8cdf20 Signed-off-by: Csókás, Bence <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]> Signed-off-by: Manuel Diewald <[email protected]> Signed-off-by: Koichiro Den <[email protected]>
1 parent 22701e7 commit bc40071

File tree

1 file changed

+25
-25
lines changed

1 file changed

+25
-25
lines changed

drivers/net/ethernet/freescale/fec_ptp.c

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,30 @@
9090
#define FEC_PTP_MAX_NSEC_PERIOD 4000000000ULL
9191
#define FEC_PTP_MAX_NSEC_COUNTER 0x80000000ULL
9292

93+
/**
94+
* fec_ptp_read - read raw cycle counter (to be used by time counter)
95+
* @cc: the cyclecounter structure
96+
*
97+
* this function reads the cyclecounter registers and is called by the
98+
* cyclecounter structure used to construct a ns counter from the
99+
* arbitrary fixed point registers
100+
*/
101+
static u64 fec_ptp_read(const struct cyclecounter *cc)
102+
{
103+
struct fec_enet_private *fep =
104+
container_of(cc, struct fec_enet_private, cc);
105+
u32 tempval;
106+
107+
tempval = readl(fep->hwp + FEC_ATIME_CTRL);
108+
tempval |= FEC_T_CTRL_CAPTURE;
109+
writel(tempval, fep->hwp + FEC_ATIME_CTRL);
110+
111+
if (fep->quirks & FEC_QUIRK_BUG_CAPTURE)
112+
udelay(1);
113+
114+
return readl(fep->hwp + FEC_ATIME);
115+
}
116+
93117
/**
94118
* fec_ptp_enable_pps
95119
* @fep: the fec_enet_private structure handle
@@ -136,7 +160,7 @@ static int fec_ptp_enable_pps(struct fec_enet_private *fep, uint enable)
136160
* NSEC_PER_SEC - ts.tv_nsec. Add the remaining nanoseconds
137161
* to current timer would be next second.
138162
*/
139-
tempval = fep->cc.read(&fep->cc);
163+
tempval = fec_ptp_read(&fep->cc);
140164
/* Convert the ptp local counter to 1588 timestamp */
141165
ns = timecounter_cyc2time(&fep->tc, tempval);
142166
ts = ns_to_timespec64(ns);
@@ -271,30 +295,6 @@ static enum hrtimer_restart fec_ptp_pps_perout_handler(struct hrtimer *timer)
271295
return HRTIMER_NORESTART;
272296
}
273297

274-
/**
275-
* fec_ptp_read - read raw cycle counter (to be used by time counter)
276-
* @cc: the cyclecounter structure
277-
*
278-
* this function reads the cyclecounter registers and is called by the
279-
* cyclecounter structure used to construct a ns counter from the
280-
* arbitrary fixed point registers
281-
*/
282-
static u64 fec_ptp_read(const struct cyclecounter *cc)
283-
{
284-
struct fec_enet_private *fep =
285-
container_of(cc, struct fec_enet_private, cc);
286-
u32 tempval;
287-
288-
tempval = readl(fep->hwp + FEC_ATIME_CTRL);
289-
tempval |= FEC_T_CTRL_CAPTURE;
290-
writel(tempval, fep->hwp + FEC_ATIME_CTRL);
291-
292-
if (fep->quirks & FEC_QUIRK_BUG_CAPTURE)
293-
udelay(1);
294-
295-
return readl(fep->hwp + FEC_ATIME);
296-
}
297-
298298
/**
299299
* fec_ptp_start_cyclecounter - create the cycle counter from hw
300300
* @ndev: network device

0 commit comments

Comments
 (0)