diff options
author | Vincent Palatin <vpalatin@chromium.org> | 2012-01-09 08:32:36 +0000 |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2012-03-03 16:56:04 +0100 |
commit | e7e982d69c43b89f7e19b63479c8b2e880fbd75c (patch) | |
tree | d933f9627c7a94066118ad31d0b016c8556c1f1b /net | |
parent | e159e4868ec1c289a7c167da681165e74308c92a (diff) | |
download | u-boot-e7e982d69c43b89f7e19b63479c8b2e880fbd75c.tar.gz u-boot-e7e982d69c43b89f7e19b63479c8b2e880fbd75c.tar.xz u-boot-e7e982d69c43b89f7e19b63479c8b2e880fbd75c.zip |
eth: remove usb-ethernet devices before re-enumerating them
Fix the crash when running several times usb_init() with a USB ethernet
device plugged.
Signed-off-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Wolfgang Grandegger <wg@denx.de>
Diffstat (limited to 'net')
-rw-r--r-- | net/eth.c | 29 |
1 files changed, 29 insertions, 0 deletions
@@ -224,6 +224,35 @@ int eth_register(struct eth_device *dev) return 0; } +int eth_unregister(struct eth_device *dev) +{ + struct eth_device *cur; + + /* No device */ + if (!eth_devices) + return -1; + + for (cur = eth_devices; cur->next != eth_devices && cur->next != dev; + cur = cur->next) + ; + + /* Device not found */ + if (cur->next != dev) + return -1; + + cur->next = dev->next; + + if (eth_devices == dev) + eth_devices = dev->next == eth_devices ? NULL : dev->next; + + if (eth_current == dev) { + eth_current = eth_devices; + eth_current_changed(); + } + + return 0; +} + int eth_initialize(bd_t *bis) { int num_devices = 0; |