Skip to content

Commit 80dc1ff

Browse files
minimaxwellkuba-moo
authored andcommitted
net: stmmac: Don't modify the global ptp ops directly
The stmmac_ptp_clock_ops are copied into the stmmac_priv structure before being registered to the PTP core. Some adjustments are made prior to that, such as the number of snapshots or max adjustment parameters. Instead of modifying the global definition, then copying into the local private data, let's first copy then modify the local parameters. Reviewed-by: Daniel Machon <[email protected]> Signed-off-by: Maxime Chevallier <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 3bf8163 commit 80dc1ff

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -298,20 +298,21 @@ void stmmac_ptp_register(struct stmmac_priv *priv)
298298
priv->pps[i].available = true;
299299
}
300300

301-
if (priv->plat->ptp_max_adj)
302-
stmmac_ptp_clock_ops.max_adj = priv->plat->ptp_max_adj;
303-
304301
/* Calculate the clock domain crossing (CDC) error if necessary */
305302
priv->plat->cdc_error_adj = 0;
306303
if (priv->plat->has_gmac4 && priv->plat->clk_ptp_rate)
307304
priv->plat->cdc_error_adj = (2 * NSEC_PER_SEC) / priv->plat->clk_ptp_rate;
308305

309-
stmmac_ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num;
310-
stmmac_ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n;
306+
priv->ptp_clock_ops = stmmac_ptp_clock_ops;
307+
308+
priv->ptp_clock_ops.n_per_out = priv->dma_cap.pps_out_num;
309+
priv->ptp_clock_ops.n_ext_ts = priv->dma_cap.aux_snapshot_n;
310+
311+
if (priv->plat->ptp_max_adj)
312+
priv->ptp_clock_ops.max_adj = priv->plat->ptp_max_adj;
311313

312314
rwlock_init(&priv->ptp_lock);
313315
mutex_init(&priv->aux_ts_lock);
314-
priv->ptp_clock_ops = stmmac_ptp_clock_ops;
315316

316317
priv->ptp_clock = ptp_clock_register(&priv->ptp_clock_ops,
317318
priv->device);

0 commit comments

Comments
 (0)