net: ethernet: renesas: rcar_gen4_ptp: Add helper to read time

Instead of accessing the Gen4 PTP specific structure directly in drivers
add a helper to read the time. This is done in preparation to
completely hide the Gen4 PTP specific structure from users.

Signed-off-by: Niklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Link: https://patch.msgid.link/20260201183745.1075399-4-niklas.soderlund+renesas@ragnatech.se
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
Niklas Söderlund 2026-02-01 19:37:44 +01:00 committed by Jakub Kicinski
parent 9afe65e7e7
commit 5640afa058
3 changed files with 13 additions and 8 deletions

View File

@ -194,6 +194,16 @@ int rcar_gen4_ptp_clock_index(struct rcar_gen4_ptp_private *priv)
}
EXPORT_SYMBOL_GPL(rcar_gen4_ptp_clock_index);
void rcar_gen4_ptp_gettime64(struct rcar_gen4_ptp_private *priv,
struct timespec64 *ts)
{
if (!priv->initialized)
return;
priv->info.gettime64(&priv->info, ts);
}
EXPORT_SYMBOL_GPL(rcar_gen4_ptp_gettime64);
MODULE_AUTHOR("Yoshihiro Shimoda");
MODULE_DESCRIPTION("Renesas R-Car Gen4 gPTP driver");
MODULE_LICENSE("GPL");

View File

@ -24,5 +24,7 @@ struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev,
void __iomem *addr);
int rcar_gen4_ptp_clock_index(struct rcar_gen4_ptp_private *priv);
void rcar_gen4_ptp_gettime64(struct rcar_gen4_ptp_private *priv,
struct timespec64 *ts);
#endif /* #ifndef __RCAR_GEN4_PTP_H__ */

View File

@ -104,13 +104,6 @@ static void rtsn_ctrl_data_irq(struct rtsn_private *priv, bool enable)
}
}
static void rtsn_get_timestamp(struct rtsn_private *priv, struct timespec64 *ts)
{
struct rcar_gen4_ptp_private *ptp_priv = priv->ptp_priv;
ptp_priv->info.gettime64(&ptp_priv->info, ts);
}
static int rtsn_tx_free(struct net_device *ndev, bool free_txed_only)
{
struct rtsn_private *priv = netdev_priv(ndev);
@ -133,7 +126,7 @@ static int rtsn_tx_free(struct net_device *ndev, bool free_txed_only)
struct skb_shared_hwtstamps shhwtstamps;
struct timespec64 ts;
rtsn_get_timestamp(priv, &ts);
rcar_gen4_ptp_gettime64(priv->ptp_priv, &ts);
memset(&shhwtstamps, 0, sizeof(shhwtstamps));
shhwtstamps.hwtstamp = timespec64_to_ktime(ts);
skb_tstamp_tx(skb, &shhwtstamps);