From patchwork Wed Dec 14 13:32:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mugunthan V N X-Patchwork-Id: 705663 X-Patchwork-Delegate: lukma@denx.de 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 3tdyDv5Q6qz9snm for ; Thu, 15 Dec 2016 00:32:47 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 85FDFA75E9; Wed, 14 Dec 2016 14:32:37 +0100 (CET) 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 gzvYtLc5Eyls; Wed, 14 Dec 2016 14:32:37 +0100 (CET) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 11B84A760B; Wed, 14 Dec 2016 14:32:36 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C8CC1A75FB for ; Wed, 14 Dec 2016 14:32:27 +0100 (CET) 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 EvtSlbAYUnPq for ; Wed, 14 Dec 2016 14:32:27 +0100 (CET) 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 lelnx194.ext.ti.com (lelnx194.ext.ti.com [198.47.27.80]) by theia.denx.de (Postfix) with ESMTPS id 141744BA81 for ; Wed, 14 Dec 2016 14:32:20 +0100 (CET) Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id uBEDWEju018552; Wed, 14 Dec 2016 07:32:14 -0600 Received: from DFLE72.ent.ti.com (dfle72.ent.ti.com [128.247.5.109]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id uBEDWEYQ029102; Wed, 14 Dec 2016 07:32:14 -0600 Received: from dlep32.itg.ti.com (157.170.170.100) by DFLE72.ent.ti.com (128.247.5.109) with Microsoft SMTP Server id 14.3.294.0; Wed, 14 Dec 2016 07:32:13 -0600 Received: from a0131834lt.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep32.itg.ti.com (8.14.3/8.13.8) with ESMTP id uBEDW692003325; Wed, 14 Dec 2016 07:32:10 -0600 From: Mugunthan V N To: Date: Wed, 14 Dec 2016 19:02:00 +0530 Message-ID: <20161214133202.19057-2-mugunthanvnm@ti.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20161214133202.19057-1-mugunthanvnm@ti.com> References: <20161214133202.19057-1-mugunthanvnm@ti.com> MIME-Version: 1.0 Cc: Marek Vasut , Tom Rini , Kishon Vijay Abraham I , Joe Hershberger Subject: [U-Boot] [PATCH v2 1/3] drivers: usb: gadget: ether: do not register usb when DM_USB and DM_ETH defined 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: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" when both DM_USB and DM_ETH are defined which denoted that usb_ether has been registered from a usb device. So registering a USB device doesn't do any thing and de-register leads to crash as it try to remove its own parent. Sample dm-tree output below. eth [ + ] |-- ethernet@4a100000 misc [ + ] `-- usb@47400000 usb_dev_gen [ + ] |-- usb@47401000 eth [ + ] | `-- usb_ether usb [ ] `-- usb@47401800 Signed-off-by: Mugunthan V N Reviewed-by: Simon Glass --- drivers/usb/gadget/ether.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/ether.c b/drivers/usb/gadget/ether.c index 046ad8ca2b..bcc8be86a5 100644 --- a/drivers/usb/gadget/ether.c +++ b/drivers/usb/gadget/ether.c @@ -105,7 +105,7 @@ struct eth_dev { struct usb_gadget *gadget; struct usb_request *req; /* for control responses */ struct usb_request *stat_req; /* for cdc & rndis status */ -#ifdef CONFIG_DM_USB +#if defined(CONFIG_DM_USB) && !defined(CONFIG_DM_ETH) struct udevice *usb_udev; #endif @@ -2316,7 +2316,7 @@ fail: /*-------------------------------------------------------------------------*/ -#ifdef CONFIG_DM_USB +#if defined(CONFIG_DM_USB) && !defined(CONFIG_DM_ETH) int dm_usb_init(struct eth_dev *e_dev) { struct udevice *dev = NULL; @@ -2342,10 +2342,12 @@ static int _usb_eth_init(struct ether_priv *priv) unsigned long timeout = USB_CONNECT_TIMEOUT; #ifdef CONFIG_DM_USB +#ifndef CONFIG_DM_ETH if (dm_usb_init(dev)) { error("USB ether not found\n"); return -ENODEV; } +#endif #else board_usb_init(0, USB_INIT_DEVICE); #endif @@ -2521,7 +2523,9 @@ void _usb_eth_halt(struct ether_priv *priv) usb_gadget_unregister_driver(&priv->eth_driver); #ifdef CONFIG_DM_USB +#ifndef CONFIG_DM_ETH device_remove(dev->usb_udev); +#endif #else board_usb_cleanup(0, USB_INIT_DEVICE); #endif