[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241202212331.7238-3-rosenp@gmail.com>
Date: Mon, 2 Dec 2024 13:23:22 -0800
From: Rosen Penev <rosenp@...il.com>
To: netdev@...r.kernel.org
Cc: Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Claudiu Manoil <claudiu.manoil@....com>,
linux-kernel@...r.kernel.org (open list)
Subject: [PATCH net-next 02/11] net: fsl_pq_mdio: use devm for mdiobus_alloc_size
Using devm avoids having to manually free. In the case of this driver,
it's simple enough that it's ideal for devm.
There also seems to be a mistake here. Using kfree instead of
mdiobus_free.
Signed-off-by: Rosen Penev <rosenp@...il.com>
---
drivers/net/ethernet/freescale/fsl_pq_mdio.c | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)
diff --git a/drivers/net/ethernet/freescale/fsl_pq_mdio.c b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
index 108e760c7a5f..d7f9d99fe782 100644
--- a/drivers/net/ethernet/freescale/fsl_pq_mdio.c
+++ b/drivers/net/ethernet/freescale/fsl_pq_mdio.c
@@ -423,7 +423,7 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
return -ENODEV;
}
- new_bus = mdiobus_alloc_size(sizeof(*priv));
+ new_bus = devm_mdiobus_alloc_size(dev, sizeof(*priv));
if (!new_bus)
return -ENOMEM;
@@ -437,17 +437,15 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
err = of_address_to_resource(np, 0, &res);
if (err < 0) {
dev_err(dev, "could not obtain address information\n");
- goto error;
+ return err;
}
snprintf(new_bus->id, MII_BUS_ID_SIZE, "%pOFn@...x", np,
(unsigned long long)res.start);
priv->map = of_iomap(np, 0);
- if (!priv->map) {
- err = -ENOMEM;
- goto error;
- }
+ if (!priv->map)
+ return -ENOMEM;
/*
* Some device tree nodes represent only the MII registers, and
@@ -502,8 +500,6 @@ static int fsl_pq_mdio_probe(struct platform_device *pdev)
if (priv->map)
iounmap(priv->map);
- kfree(new_bus);
-
return err;
}
@@ -517,7 +513,6 @@ static void fsl_pq_mdio_remove(struct platform_device *pdev)
mdiobus_unregister(bus);
iounmap(priv->map);
- mdiobus_free(bus);
}
static struct platform_driver fsl_pq_mdio_driver = {
--
2.47.0
Powered by blists - more mailing lists