From: Rosen Penev <rosenp@gmail.com>
To: netdev@vger.kernel.org
Subject: [PATCH net-next 10/11] net: gianfar: alloc queues with devm
Date: Thu, 10 Jul 2025 13:40:31 -0700 [thread overview]
Message-ID: <20250710204032.650152-11-rosenp@gmail.com> (raw)
In-Reply-To: <20250710204032.650152-1-rosenp@gmail.com>
Remove the freeing functions as they no longer serve a purpose. devm
handles this automatically.
There seems to be a mistake here where free_tx_queue is called on
failure. Just let devm deal with it.
Signed-off-by: Rosen Penev <rosenp@gmail.com>
Reviewed-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
---
drivers/net/ethernet/freescale/gianfar.c | 38 +++++-------------------
1 file changed, 7 insertions(+), 31 deletions(-)
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index a93244415274..bc1d7c4bd1a7 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -413,8 +413,8 @@ static int gfar_alloc_tx_queues(struct gfar_private *priv)
int i;
for (i = 0; i < priv->num_tx_queues; i++) {
- priv->tx_queue[i] = kzalloc(sizeof(struct gfar_priv_tx_q),
- GFP_KERNEL);
+ priv->tx_queue[i] = devm_kzalloc(
+ priv->dev, sizeof(struct gfar_priv_tx_q), GFP_KERNEL);
if (!priv->tx_queue[i])
return -ENOMEM;
@@ -431,8 +431,8 @@ static int gfar_alloc_rx_queues(struct gfar_private *priv)
int i;
for (i = 0; i < priv->num_rx_queues; i++) {
- priv->rx_queue[i] = kzalloc(sizeof(struct gfar_priv_rx_q),
- GFP_KERNEL);
+ priv->rx_queue[i] = devm_kzalloc(
+ priv->dev, sizeof(struct gfar_priv_rx_q), GFP_KERNEL);
if (!priv->rx_queue[i])
return -ENOMEM;
@@ -442,22 +442,6 @@ static int gfar_alloc_rx_queues(struct gfar_private *priv)
return 0;
}
-static void gfar_free_tx_queues(struct gfar_private *priv)
-{
- int i;
-
- for (i = 0; i < priv->num_tx_queues; i++)
- kfree(priv->tx_queue[i]);
-}
-
-static void gfar_free_rx_queues(struct gfar_private *priv)
-{
- int i;
-
- for (i = 0; i < priv->num_rx_queues; i++)
- kfree(priv->rx_queue[i]);
-}
-
static void unmap_group_regs(struct gfar_private *priv)
{
int i;
@@ -678,16 +662,16 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
err = gfar_alloc_tx_queues(priv);
if (err)
- goto tx_alloc_failed;
+ return err;
err = gfar_alloc_rx_queues(priv);
if (err)
- goto rx_alloc_failed;
+ return err;
err = of_property_read_string(np, "model", &model);
if (err) {
pr_err("Device model property missing, aborting\n");
- goto rx_alloc_failed;
+ return err;
}
/* Init Rx queue filer rule set linked list */
@@ -796,10 +780,6 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
err_grp_init:
unmap_group_regs(priv);
-rx_alloc_failed:
- gfar_free_rx_queues(priv);
-tx_alloc_failed:
- gfar_free_tx_queues(priv);
return err;
}
@@ -3308,8 +3288,6 @@ static int gfar_probe(struct platform_device *ofdev)
if (of_phy_is_fixed_link(np))
of_phy_deregister_fixed_link(np);
unmap_group_regs(priv);
- gfar_free_rx_queues(priv);
- gfar_free_tx_queues(priv);
of_node_put(priv->phy_node);
of_node_put(priv->tbi_node);
return err;
@@ -3327,8 +3305,6 @@ static void gfar_remove(struct platform_device *ofdev)
of_phy_deregister_fixed_link(np);
unmap_group_regs(priv);
- gfar_free_rx_queues(priv);
- gfar_free_tx_queues(priv);
}
#ifdef CONFIG_PM
--
2.50.0
next prev parent reply other threads:[~2025-07-10 20:40 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-10 20:40 [PATCH net-next 00/11] gianfar and mdio: modernize Rosen Penev
2025-07-10 20:40 ` [PATCH net-next 01/11] net: fsl_pq_mdio: use dev variable in _probe Rosen Penev
2025-07-10 20:40 ` [PATCH net-next 02/11] net: fsl_pq_mdio: use devm for mdiobus_alloc_size Rosen Penev
2025-07-10 20:40 ` [PATCH net-next 03/11] net: fsl_pq_mdio: use platform_get_resource Rosen Penev
2025-07-10 20:40 ` [PATCH net-next 04/11] net: fsl_pq_mdio: use devm for of_iomap Rosen Penev
2025-07-10 20:40 ` [PATCH net-next 05/11] net: fsl_pq_mdio: return directly in probe Rosen Penev
2025-07-10 20:40 ` [PATCH net-next 06/11] net: gianfar: use devm_alloc_etherdev_mqs Rosen Penev
2025-07-10 20:40 ` [PATCH net-next 07/11] net: gianfar: use devm for register_netdev Rosen Penev
2025-07-10 20:40 ` [PATCH net-next 08/11] net: gianfar: assign ofdev to priv struct Rosen Penev
2025-07-10 20:40 ` [PATCH net-next 09/11] net: gianfar: remove free_gfar_dev Rosen Penev
2025-07-10 20:40 ` Rosen Penev [this message]
2025-07-10 20:40 ` [PATCH net-next 11/11] net: gianfar: iomap with devm Rosen Penev
2025-07-10 22:15 ` [PATCH net-next 00/11] gianfar and mdio: modernize Jakub Kicinski
-- strict thread matches above, loose matches on Subject: below --
2024-12-02 21:23 Rosen Penev
2024-12-02 21:23 ` [PATCH net-next 10/11] net: gianfar: alloc queues with devm Rosen Penev
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=20250710204032.650152-11-rosenp@gmail.com \
--to=rosenp@gmail.com \
--cc=netdev@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.