]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: ethernet: renesas: rcar_gen4_ptp: Move address assignment
authorNiklas Söderlund <niklas.soderlund+renesas@ragnatech.se>
Sun, 1 Feb 2026 18:37:42 +0000 (19:37 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 4 Feb 2026 03:35:37 +0000 (19:35 -0800)
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>
drivers/net/ethernet/renesas/rcar_gen4_ptp.c
drivers/net/ethernet/renesas/rcar_gen4_ptp.h
drivers/net/ethernet/renesas/rswitch_main.c
drivers/net/ethernet/renesas/rtsn.c

index d0979abd36de4a1d190f46fee6803ae14c9468eb..3fd835128cc81833ef1ffd7c5aeff810c3664f1a 100644 (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);
index 9a9c232c854ef46bdb96f3f5765e5ae15967b082..b71aba873795179d5e9ddfb5bbd9734cddef1ad6 100644 (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__ */
index e14b21148f27a54430a7313861505ce4c2b5df38..ab0b40d4f4fbb6b55866c084f063ac2a9952b641 100644 (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) {
index fdb1e7b7fb066d37023e51c4144571855c5f8bd5..d4b955c87f1b6323d951d0ca7f33dd686eceabf2 100644 (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;
        }