From patchwork Thu Oct 8 04:32:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 527589 X-Patchwork-Delegate: joe.hershberger@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id AAD3C1402A8 for ; Thu, 8 Oct 2015 15:30:34 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=PBNf065m; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 3E9C94B8BB; Thu, 8 Oct 2015 06:30:29 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id yB6WVdhR_9b1; Thu, 8 Oct 2015 06:30:29 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 727854B8BC; Thu, 8 Oct 2015 06:30:21 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id A9A924B8A7 for ; Thu, 8 Oct 2015 06:30:13 +0200 (CEST) Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rcZkTk4ZAy4D for ; Thu, 8 Oct 2015 06:30:13 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from mail-pa0-f46.google.com (mail-pa0-f46.google.com [209.85.220.46]) by theia.denx.de (Postfix) with ESMTPS id 3DCC34B8A3 for ; Thu, 8 Oct 2015 06:30:10 +0200 (CEST) Received: by padhy16 with SMTP id hy16so41992473pad.1 for ; Wed, 07 Oct 2015 21:30:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:in-reply-to:references; bh=dBQgEhfFPG3n9hkSzK8RC/1KEqdRSp1RrAZDy5iWJWo=; b=PBNf065mT/OOisxiEfy7dd5RQS69lSDl3HMXMm4bIZSnlAgjZZYMBWVLlfxNsstjsG fYjUuxK+NJBPLlgzWcOV/Y9heG/O8Q1/LofEylIFJGApgzlVHxOwg9Ie5TROba74kPdN t9irVKjVf8Q5x8JvApJ256s7t1I/sfvxDlgQRwXwrK9TlPhAiLzLd8ZF9rXVW8cx5jeH RLb9xoY6nOz9Ij7eMSUi0h8S5TMsw4aOYWTlKwGAC7CKLHmgi2aEy8mtoKZMqXsNQ7x6 /jnm5/HES42SDSDmkVMPLTQPNa90V1ReXHd8IgFP+EupTmdgYQwZ1gBBz1hqUVsmSHnW 2s+g== X-Received: by 10.66.100.165 with SMTP id ez5mr5458458pab.63.1444278608326; Wed, 07 Oct 2015 21:30:08 -0700 (PDT) Received: from ala-d2121-lx1.wrs.com (unknown-157-139.windriver.com. [147.11.157.139]) by smtp.gmail.com with ESMTPSA id z4sm20743581par.6.2015.10.07.21.30.07 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Oct 2015 21:30:07 -0700 (PDT) From: Bin Meng To: Joe Hershberger , Simon Glass , U-Boot Mailing List Date: Wed, 7 Oct 2015 21:32:38 -0700 Message-Id: <1444278760-31530-2-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 In-Reply-To: <1444278760-31530-1-git-send-email-bmeng.cn@gmail.com> References: <1444278760-31530-1-git-send-email-bmeng.cn@gmail.com> Subject: [U-Boot] [PATCH v2 2/4] net: designware: Add driver remove support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" 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 Acked-by: Simon Glass --- Changes in v2: None drivers/net/designware.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 6433896..a6c39c3 100644 --- a/drivers/net/designware.c +++ b/drivers/net/designware.c @@ -613,6 +613,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, @@ -653,6 +664,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),