net: ethernet: renesas: rcar_gen4_ptp: Move address assignment

Instead of accessing the Gen4 PTP specific structure directly in drivers
move the device address assignment into the preparation call. 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-2-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:42 +01:00
committed by Jakub Kicinski
parent 6dfa3df797
commit 642377346a
4 changed files with 20 additions and 16 deletions

View File

@@ -168,7 +168,8 @@ int rcar_gen4_ptp_unregister(struct rcar_gen4_ptp_private *ptp_priv)
}
EXPORT_SYMBOL_GPL(rcar_gen4_ptp_unregister);
struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev)
struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev,
void __iomem *addr)
{
struct rcar_gen4_ptp_private *ptp;
@@ -178,6 +179,8 @@ struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev)
ptp->info = rcar_gen4_ptp_info;
ptp->addr = addr;
return ptp;
}
EXPORT_SYMBOL_GPL(rcar_gen4_ptp_alloc);

View File

@@ -20,6 +20,7 @@ struct rcar_gen4_ptp_private {
int rcar_gen4_ptp_register(struct rcar_gen4_ptp_private *ptp_priv, u32 rate);
int rcar_gen4_ptp_unregister(struct rcar_gen4_ptp_private *ptp_priv);
struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev);
struct rcar_gen4_ptp_private *rcar_gen4_ptp_alloc(struct platform_device *pdev,
void __iomem *addr);
#endif /* #ifndef __RCAR_GEN4_PTP_H__ */

View File

@@ -2150,17 +2150,16 @@ static int renesas_eth_sw_probe(struct platform_device *pdev)
if (attr)
priv->etha_no_runtime_change = true;
priv->ptp_priv = rcar_gen4_ptp_alloc(pdev);
if (!priv->ptp_priv)
return -ENOMEM;
platform_set_drvdata(pdev, priv);
priv->pdev = pdev;
priv->addr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->addr))
return PTR_ERR(priv->addr);
priv->ptp_priv->addr = priv->addr + RSWITCH_GPTP_OFFSET_S4;
priv->ptp_priv =
rcar_gen4_ptp_alloc(pdev, priv->addr + RSWITCH_GPTP_OFFSET_S4);
if (!priv->ptp_priv)
return -ENOMEM;
ret = dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(40));
if (ret < 0) {

View File

@@ -1227,6 +1227,7 @@ static int rtsn_probe(struct platform_device *pdev)
{
struct rtsn_private *priv;
struct net_device *ndev;
void __iomem *ptpaddr;
struct resource *res;
int ret;
@@ -1239,12 +1240,6 @@ static int rtsn_probe(struct platform_device *pdev)
priv->pdev = pdev;
priv->ndev = ndev;
priv->ptp_priv = rcar_gen4_ptp_alloc(pdev);
if (!priv->ptp_priv) {
ret = -ENOMEM;
goto error_free;
}
spin_lock_init(&priv->lock);
platform_set_drvdata(pdev, priv);
@@ -1288,9 +1283,15 @@ static int rtsn_probe(struct platform_device *pdev)
goto error_free;
}
priv->ptp_priv->addr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(priv->ptp_priv->addr)) {
ret = PTR_ERR(priv->ptp_priv->addr);
ptpaddr = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(ptpaddr)) {
ret = PTR_ERR(ptpaddr);
goto error_free;
}
priv->ptp_priv = rcar_gen4_ptp_alloc(pdev, ptpaddr);
if (!priv->ptp_priv) {
ret = -ENOMEM;
goto error_free;
}