From: Rosen Penev <rosenp@gmail.com>
To: netdev@vger.kernel.org
Cc: timur@kernel.org, davem@davemloft.net, edumazet@google.com,
kuba@kernel.org, pabeni@redhat.com, linux-kernel@vger.kernel.org
Subject: [PATCH] net: qualcomm: emac: use devm for alloc_etherdev
Date: Wed, 7 Aug 2024 20:57:51 -0700 [thread overview]
Message-ID: <20240808035800.5059-1-rosenp@gmail.com> (raw)
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
next reply other threads:[~2024-08-08 3:58 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-08 3:57 Rosen Penev [this message]
2024-08-08 15:40 ` [PATCH] net: qualcomm: emac: use devm for alloc_etherdev Jakub Kicinski
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240808035800.5059-1-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=timur@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).