From: Rosen Penev <rosenp@gmail.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, edumazet@google.com, kuba@kernel.org,
pabeni@redhat.com, linux-kernel@vger.kernel.org,
jacob.e.keller@intel.com, horms@kernel.org, sd@queasysnail.net,
chunkeey@gmail.com
Subject: [PATCHv3 net-next 1/9] net: ibm: emac: use devm for alloc_etherdev
Date: Thu, 5 Sep 2024 13:14:58 -0700 [thread overview]
Message-ID: <20240905201506.12679-2-rosenp@gmail.com> (raw)
In-Reply-To: <20240905201506.12679-1-rosenp@gmail.com>
Allows to simplify the code slightly. This is safe to do as free_netdev
gets called last.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/net/ethernet/ibm/emac/core.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index a19d098f2e2b..348702f462bd 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -3053,7 +3053,7 @@ static int emac_probe(struct platform_device *ofdev)
/* Allocate our net_device structure */
err = -ENOMEM;
- ndev = alloc_etherdev(sizeof(struct emac_instance));
+ ndev = devm_alloc_etherdev(&ofdev->dev, sizeof(struct emac_instance));
if (!ndev)
goto err_gone;
@@ -3072,7 +3072,7 @@ static int emac_probe(struct platform_device *ofdev)
/* Init various config data based on device-tree */
err = emac_init_config(dev);
if (err)
- goto err_free;
+ goto err_gone;
/* Get interrupts. EMAC irq is mandatory, WOL irq is optional */
dev->emac_irq = irq_of_parse_and_map(np, 0);
@@ -3080,7 +3080,7 @@ static int emac_probe(struct platform_device *ofdev)
if (!dev->emac_irq) {
printk(KERN_ERR "%pOF: Can't map main interrupt\n", np);
err = -ENODEV;
- goto err_free;
+ goto err_gone;
}
ndev->irq = dev->emac_irq;
@@ -3239,8 +3239,6 @@ static int emac_probe(struct platform_device *ofdev)
irq_dispose_mapping(dev->wol_irq);
if (dev->emac_irq)
irq_dispose_mapping(dev->emac_irq);
- err_free:
- free_netdev(ndev);
err_gone:
/* if we were on the bootlist, remove us as we won't show up and
* wake up all waiters to notify them in case they were waiting
@@ -3289,7 +3287,6 @@ static void emac_remove(struct platform_device *ofdev)
if (dev->emac_irq)
irq_dispose_mapping(dev->emac_irq);
- free_netdev(dev->ndev);
}
/* XXX Features in here should be replaced by properties... */
--
2.46.0
next prev parent reply other threads:[~2024-09-05 20:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 20:14 [PATCHv3 net-next 0/9] net: ibm: emac: modernize a bit Rosen Penev
2024-09-05 20:14 ` Rosen Penev [this message]
2024-09-05 21:16 ` [PATCHv3 net-next 1/9] net: ibm: emac: use devm for alloc_etherdev Andrew Lunn
2024-09-05 20:14 ` [PATCHv3 net-next 2/9] net: ibm: emac: manage emac_irq with devm Rosen Penev
2024-09-05 21:17 ` Andrew Lunn
2024-09-05 20:15 ` [PATCHv3 net-next 3/9] net: ibm: emac: use devm for of_iomap Rosen Penev
2024-09-05 21:17 ` Andrew Lunn
2024-09-05 20:15 ` [PATCHv3 net-next 4/9] net: ibm: emac: remove mii_bus with devm Rosen Penev
2024-09-05 21:19 ` Andrew Lunn
2024-09-05 20:15 ` [PATCHv3 net-next 5/9] net: ibm: emac: use devm for register_netdev Rosen Penev
2024-09-05 21:19 ` Andrew Lunn
2024-09-05 20:15 ` [PATCHv3 net-next 6/9] net: ibm: emac: use netdev's phydev directly Rosen Penev
2024-09-05 21:21 ` Andrew Lunn
2024-09-07 19:32 ` Christophe JAILLET
2024-09-07 19:58 ` Rosen Penev
2024-09-05 20:15 ` [PATCHv3 net-next 7/9] net: ibm: emac: replace of_get_property Rosen Penev
2024-09-05 21:22 ` Andrew Lunn
2024-09-05 20:15 ` [PATCHv3 net-next 8/9] net: ibm: emac: remove all waiting code Rosen Penev
2024-09-05 20:15 ` [PATCHv3 net-next 9/9] net: ibm: emac: get rid of wol_irq Rosen Penev
2024-09-05 21:27 ` Andrew Lunn
2024-09-05 22:28 ` Rosen Penev
2024-09-07 18:29 ` kernel test robot
2024-09-07 23:11 ` kernel test robot
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=20240905201506.12679-2-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=chunkeey@gmail.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=jacob.e.keller@intel.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=sd@queasysnail.net \
/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).