diff mbox

[U-Boot,v2,3/4] net: pch_gbe: Add driver remove support

Message ID 1444278760-31530-3-git-send-email-bmeng.cn@gmail.com
State Accepted
Delegated to: Joe Hershberger
Headers show

Commit Message

Bin Meng Oct. 8, 2015, 4:32 a.m. UTC
In pch_gbe_probe(), some additional resources are allocated
(eg: mdio, phy). We should free these in the driver remove phase.
Add pch_gbe_remove() to clean it up.

Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
---

Changes in v2: None

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

Comments

Joe Hershberger Oct. 28, 2015, 7:50 p.m. UTC | #1
Hi Bin,

On Wed, Oct 7, 2015 at 11:32 PM, Bin Meng <bmeng.cn@gmail.com> wrote:
> In pch_gbe_probe(), some additional resources are allocated
> (eg: mdio, phy). We should free these in the driver remove phase.
> Add pch_gbe_remove() to clean it up.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger Oct. 29, 2015, 7:33 p.m. UTC | #2
On Wed, Oct 7, 2015 at 11:32 PM, Bin Meng <bmeng.cn@gmail.com> wrote:
> In pch_gbe_probe(), some additional resources are allocated
> (eg: mdio, phy). We should free these in the driver remove phase.
> Add pch_gbe_remove() to clean it up.
>
> Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot-net/master, thanks!
-Joe
diff mbox

Patch

diff --git a/drivers/net/pch_gbe.c b/drivers/net/pch_gbe.c
index 004fcf8..dfc0100 100644
--- a/drivers/net/pch_gbe.c
+++ b/drivers/net/pch_gbe.c
@@ -452,6 +452,17 @@  int pch_gbe_probe(struct udevice *dev)
 	return pch_gbe_phy_init(dev);
 }
 
+int pch_gbe_remove(struct udevice *dev)
+{
+	struct pch_gbe_priv *priv = dev_get_priv(dev);
+
+	free(priv->phydev);
+	mdio_unregister(priv->bus);
+	mdio_free(priv->bus);
+
+	return 0;
+}
+
 static const struct eth_ops pch_gbe_ops = {
 	.start = pch_gbe_start,
 	.send = pch_gbe_send,
@@ -470,6 +481,7 @@  U_BOOT_DRIVER(eth_pch_gbe) = {
 	.id = UCLASS_ETH,
 	.of_match = pch_gbe_ids,
 	.probe = pch_gbe_probe,
+	.remove = pch_gbe_remove,
 	.ops = &pch_gbe_ops,
 	.priv_auto_alloc_size = sizeof(struct pch_gbe_priv),
 	.platdata_auto_alloc_size = sizeof(struct eth_pdata),