diff options
author | Bin Meng <bmeng.cn@gmail.com> | 2015-12-21 22:43:39 -0800 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2016-01-07 10:27:07 -0700 |
commit | 4cdc2c8cc018ba90050bee7622148032af7341ec (patch) | |
tree | 2d0acf6ce5d9d68ce17b829930237fedb0a1e661 | |
parent | a671c4f2bea6215140b34726900d4f0aa5892e6a (diff) |
dm: eth: Stick to 'ethact' when 'ethrotate' is 'no' in eth_init()
When 'ethrotate' variable is set to 'no' and 'ethact' variable
is already set to an ethernet device, we should stick to 'ethact'.
Signed-off-by: Bin Meng <bmeng.cn@gmail.com>
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
Tested-by: Simon Glass <sjg@chromium.org>
-rw-r--r-- | net/eth.c | 24 |
1 files changed, 20 insertions, 4 deletions
@@ -337,14 +337,30 @@ U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr); int eth_init(void) { - struct udevice *current; + char *ethact = getenv("ethact"); + char *ethrotate = getenv("ethrotate"); + struct udevice *current = NULL; struct udevice *old_current; int ret = -ENODEV; - current = eth_get_dev(); + /* + * When 'ethrotate' variable is set to 'no' and 'ethact' variable + * is already set to an ethernet device, we should stick to 'ethact'. + */ + if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0)) { + if (ethact) { + current = eth_get_dev_by_name(ethact); + if (!current) + return -EINVAL; + } + } + if (!current) { - printf("No ethernet found.\n"); - return -ENODEV; + current = eth_get_dev(); + if (!current) { + printf("No ethernet found.\n"); + return -ENODEV; + } } old_current = current; |