[U-Boot] [PATCH v2 1/3] drivers: usb: gadget: ether: do not register usb when DM_USB and DM_ETH defined
Mugunthan V N
mugunthanvnm at ti.com
Wed Dec 14 14:32:00 CET 2016
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 at 4a100000
misc [ + ] `-- usb at 47400000
usb_dev_gen [ + ] |-- usb at 47401000
eth [ + ] | `-- usb_ether
usb [ ] `-- usb at 47401800
Signed-off-by: Mugunthan V N <mugunthanvnm at ti.com>
---
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
--
2.11.0
More information about the U-Boot
mailing list