netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: qualcomm: emac: use devm for alloc_etherdev
@ 2024-08-08  3:57 Rosen Penev
  2024-08-08 15:40 ` Jakub Kicinski
  0 siblings, 1 reply; 2+ messages in thread
From: Rosen Penev @ 2024-08-08  3:57 UTC (permalink / raw)
  To: netdev; +Cc: timur, davem, edumazet, kuba, pabeni, linux-kernel

Removes the need to free. It's safe as it is created first and destroyed
last.

Added return with dev_err_probe. Saves 1 line.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/ethernet/qualcomm/emac/emac.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/qualcomm/emac/emac.c b/drivers/net/ethernet/qualcomm/emac/emac.c
index 99d4647bf245..bb0d91dcce2e 100644
--- a/drivers/net/ethernet/qualcomm/emac/emac.c
+++ b/drivers/net/ethernet/qualcomm/emac/emac.c
@@ -608,7 +608,7 @@ static int emac_probe(struct platform_device *pdev)
 		return ret;
 	}
 
-	netdev = alloc_etherdev(sizeof(struct emac_adapter));
+	netdev = devm_alloc_etherdev(&pdev->dev, sizeof(struct emac_adapter));
 	if (!netdev)
 		return -ENOMEM;
 
@@ -630,14 +630,12 @@ static int emac_probe(struct platform_device *pdev)
 
 	ret = emac_probe_resources(pdev, adpt);
 	if (ret)
-		goto err_undo_netdev;
+		return ret;
 
 	/* initialize clocks */
 	ret = emac_clks_phase1_init(pdev, adpt);
-	if (ret) {
-		dev_err(&pdev->dev, "could not initialize clocks\n");
-		goto err_undo_netdev;
-	}
+	if (ret)
+		return dev_err_probe(&pdev->dev, ret, "could not initialize clocks\n");
 
 	netdev->watchdog_timeo = EMAC_WATCHDOG_TIME;
 	netdev->irq = adpt->irq.irq;
@@ -712,9 +710,6 @@ static int emac_probe(struct platform_device *pdev)
 	mdiobus_unregister(adpt->mii_bus);
 err_undo_clocks:
 	emac_clks_teardown(adpt);
-err_undo_netdev:
-	free_netdev(netdev);
-
 	return ret;
 }
 
@@ -740,8 +735,6 @@ static void emac_remove(struct platform_device *pdev)
 	if (adpt->phy.digital)
 		iounmap(adpt->phy.digital);
 	iounmap(adpt->phy.base);
-
-	free_netdev(netdev);
 }
 
 static void emac_shutdown(struct platform_device *pdev)
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: qualcomm: emac: use devm for alloc_etherdev
  2024-08-08  3:57 [PATCH] net: qualcomm: emac: use devm for alloc_etherdev Rosen Penev
@ 2024-08-08 15:40 ` Jakub Kicinski
  0 siblings, 0 replies; 2+ messages in thread
From: Jakub Kicinski @ 2024-08-08 15:40 UTC (permalink / raw)
  To: Rosen Penev; +Cc: netdev, timur, davem, edumazet, pabeni, linux-kernel

On Wed,  7 Aug 2024 20:57:51 -0700 Rosen Penev wrote:
> Removes the need to free. It's safe as it is created first and destroyed
> last.
> 
> Added return with dev_err_probe. Saves 1 line.

Again, do you have the HW to test this?
Please don't go around "improving" old drivers which aren't broken.
-- 
pw-bot: cr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-08-08 15:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-08  3:57 [PATCH] net: qualcomm: emac: use devm for alloc_etherdev Rosen Penev
2024-08-08 15:40 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).