[PATCH net-next 6/6] net: gianfar: use devm for of_iomap

Rosen Penev
2024-10-01T21:22:14Z

Avoids having to manually unmap.

Removes all gotos in probe.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/ethernet/freescale/gianfar.c | 26 +++++-------------------
1 file changed, 5 insertions(+), 21 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 78fdab3c6f77..96eeef0d6bd3 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -441,15 +441,6 @@ static int gfar_alloc_rx_queues(struct gfar_private *priv)
return 0;
}

-static void unmap_group_regs(struct gfar_private *priv)
-{
- int i;
-
- for (i = 0; i < MAXGROUPS; i++)
- if (priv->gfargrp[i].regs)
- iounmap(priv->gfargrp[i].regs);
-}
-
static void disable_napi(struct gfar_private *priv)
{
int i;
@@ -483,7 +474,7 @@ static int gfar_parse_group(struct device_node *np,
return -ENOMEM;
}

- grp->regs = of_iomap(np, 0);
+ grp->regs = devm_of_iomap(priv->dev, np, 0, NULL);
if (!grp->regs)
return -ENOMEM;

@@ -698,13 +689,13 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
err = gfar_parse_group(child, priv, model);
if (err) {
of_node_put(child);
- goto err_grp_init;
+ return err;
}
}
} else { /* SQ_SG_MODE */
err = gfar_parse_group(np, priv, model);
if (err)
- goto err_grp_init;
+ return err;
}

if (of_property_read_bool(np, "bd-stash")) {
@@ -727,7 +718,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)

err = of_get_ethdev_address(np, dev);
if (err == -EPROBE_DEFER)
- goto err_grp_init;
+ return err;
if (err) {
eth_hw_addr_random(dev);
dev_info(&ofdev->dev, "Using random MAC address: %pM\n", dev->dev_addr);
@@ -775,7 +766,7 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
if (!priv->phy_node && of_phy_is_fixed_link(np)) {
err = of_phy_register_fixed_link(np);
if (err)
- goto err_grp_init;
+ return err;

priv->phy_node = of_node_get(np);
}
@@ -784,10 +775,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
priv->tbi_node = of_parse_phandle(np, "tbi-handle", 0);

return 0;
-
-err_grp_init:
- unmap_group_regs(priv);
- return err;
}

static u32 cluster_entry_per_class(struct gfar_private *priv, u32 rqfar,
@@ -3293,7 +3280,6 @@ static int gfar_probe(struct platform_device *ofdev)
register_fail:
if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
- unmap_group_regs(priv);
of_node_put(priv->phy_node);
of_node_put(priv->tbi_node);
return err;
@@ -3309,8 +3295,6 @@ static void gfar_remove(struct platform_device *ofdev)

if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
-
- unmap_group_regs(priv);
}

#ifdef CONFIG_PM
--
2.46.2