net: qualcomm: emac: use devm for alloc_etherdev
Subsystems (3)
PATCH 1/1 net: qualcomm: emac: use devm for alloc_etherdev
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 <[email protected]>
--- drivers/net/ethernet/qualcomm/emac/emac.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-)
drivers/net/ethernet/qualcomm/emac/emac.c +4 -11
@@ -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)
Signature · 1 line
2.45.2
Jakub Kicinski
maintainerQuoted 4 lines · 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.
Signature · 1 line
pw-bot: cr