[U-Boot] [PATCH 2/5] net: designware: Add driver remove support

Bin Meng bmeng.cn at gmail.com
Fri Sep 4 16:53:32 CEST 2015


In designware_eth_probe(), some additional resources are allocated
(eg: mdio, phy). We should free these in the driver remove phase.
Add designware_eth_remove() to clean it up.

Signed-off-by: Bin Meng <bmeng.cn at gmail.com>
---

 drivers/net/designware.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index d45340c..d2aedb0 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -609,6 +609,17 @@ static int designware_eth_probe(struct udevice *dev)
 	return ret;
 }
 
+static int designware_eth_remove(struct udevice *dev)
+{
+	struct dw_eth_dev *priv = dev_get_priv(dev);
+
+	free(priv->phydev);
+	mdio_unregister(priv->bus);
+	mdio_free(priv->bus);
+
+	return 0;
+}
+
 static const struct eth_ops designware_eth_ops = {
 	.start			= designware_eth_start,
 	.send			= designware_eth_send,
@@ -649,6 +660,7 @@ U_BOOT_DRIVER(eth_designware) = {
 	.ofdata_to_platdata = designware_eth_ofdata_to_platdata,
 	.bind	= designware_eth_bind,
 	.probe	= designware_eth_probe,
+	.remove	= designware_eth_remove,
 	.ops	= &designware_eth_ops,
 	.priv_auto_alloc_size = sizeof(struct dw_eth_dev),
 	.platdata_auto_alloc_size = sizeof(struct eth_pdata),
-- 
1.8.2.1



More information about the U-Boot mailing list