diff mbox series

net: qualcomm: emac: use devm for alloc_etherdev

Message ID 20240808035800.5059-1-rosenp@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: qualcomm: emac: use devm for alloc_etherdev | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 5 of 5 maintainers
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch warning WARNING: line length of 87 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest warning net-next-2024-08-08--15-00 (tests: 705)

Commit Message

Rosen Penev Aug. 8, 2024, 3:57 a.m. UTC
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(-)

Comments

Jakub Kicinski Aug. 8, 2024, 3:40 p.m. UTC | #1
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.
diff mbox series

Patch

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)