From patchwork Thu Oct 8 04:32:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bin Meng X-Patchwork-Id: 527587 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 A61381402A8 for ; Thu, 8 Oct 2015 15:30:17 +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=ZB7XXLZi; dkim-atps=neutral Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 12AAF4B8AB; Thu, 8 Oct 2015 06:30:16 +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 umKeNVOTYvfS; Thu, 8 Oct 2015 06:30:15 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 0B1534B89A; Thu, 8 Oct 2015 06:30:15 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id EACAB4B89A for ; Thu, 8 Oct 2015 06:30:12 +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 3xn6pQ3giONC for ; Thu, 8 Oct 2015 06:30:12 +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-f53.google.com (mail-pa0-f53.google.com [209.85.220.53]) by theia.denx.de (Postfix) with ESMTPS id 6E4594B899 for ; Thu, 8 Oct 2015 06:30:08 +0200 (CEST) Received: by pacex6 with SMTP id ex6so42097369pac.0 for ; Wed, 07 Oct 2015 21:30:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=HXXdb6QuAt6x7jLKiUswB2nfW8nQqNXIRjYcwCr8y9A=; b=ZB7XXLZieWrnX0JJ5/N/TAk2UuJzQxnDWLSSdMe3M82M+WlPPB5mc4gg/AwZUtqOD3 d4MkQRD/XHD0vq3ErsWGKEV2ldHrXOpP03AOgzqJ+emQqeBqZhxcFhDAHwk1iljZSB1J nKQFg9tX/9kpFUDeAYi2urqN3xYlJa0cVwXoAqzkdX+LWG/y4ptDPrzuYQNuYRUJdMla y+4qoqQiE+SFed6QK/5fjQpy6gykKAT1vvz5si0EGfeopN9kY5vCSBjg/D3G6QHdaC9j +1EZ50mqau8LfJHetzpCDIXg9hoSAi+tNb3ZovXq6k+q1Rs28VqD+HrHaK49xkky/ytC Wd4A== X-Received: by 10.66.160.100 with SMTP id xj4mr5591053pab.39.1444278607603; Wed, 07 Oct 2015 21:30:07 -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.06 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 07 Oct 2015 21:30:06 -0700 (PDT) From: Bin Meng To: Joe Hershberger , Simon Glass , U-Boot Mailing List Date: Wed, 7 Oct 2015 21:32:37 -0700 Message-Id: <1444278760-31530-1-git-send-email-bmeng.cn@gmail.com> X-Mailer: git-send-email 1.7.9.5 Subject: [U-Boot] [PATCH v2 1/4] net: mdio: Add mdio_free() and mdio_unregister() API 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" Currently there is no API to uninitialize mdio. Add two APIs for this. Signed-off-by: Bin Meng Acked-by: Joe Hershberger --- Changes in v2: None common/miiphyutil.c | 19 +++++++++++++++++++ include/miiphy.h | 2 ++ 2 files changed, 21 insertions(+) diff --git a/common/miiphyutil.c b/common/miiphyutil.c index c88c28a..e499b58 100644 --- a/common/miiphyutil.c +++ b/common/miiphyutil.c @@ -152,6 +152,11 @@ struct mii_dev *mdio_alloc(void) return bus; } +void mdio_free(struct mii_dev *bus) +{ + free(bus); +} + int mdio_register(struct mii_dev *bus) { if (!bus || !bus->name || !bus->read || !bus->write) @@ -173,6 +178,20 @@ int mdio_register(struct mii_dev *bus) return 0; } +int mdio_unregister(struct mii_dev *bus) +{ + if (!bus) + return 0; + + /* delete it from the list */ + list_del(&bus->link); + + if (current_mii == bus) + current_mii = NULL; + + return 0; +} + void mdio_list_devices(void) { struct list_head *entry; diff --git a/include/miiphy.h b/include/miiphy.h index 088797e..af12274 100644 --- a/include/miiphy.h +++ b/include/miiphy.h @@ -59,7 +59,9 @@ struct phy_device *mdio_phydev_for_ethname(const char *devname); void miiphy_listdev(void); struct mii_dev *mdio_alloc(void); +void mdio_free(struct mii_dev *bus); int mdio_register(struct mii_dev *bus); +int mdio_unregister(struct mii_dev *bus); void mdio_list_devices(void); #ifdef CONFIG_BITBANGMII