From: Bin Meng Date: Tue, 22 Dec 2015 06:43:39 +0000 (-0800) Subject: dm: eth: Stick to 'ethact' when 'ethrotate' is 'no' in eth_init() X-Git-Tag: v2025.01-rc5-pxa1908~10812^2~5 X-Git-Url: http://git.dujemihanovic.xyz/img/%7B%7B%20%28.OutputFormats.Get?a=commitdiff_plain;h=4cdc2c8cc018ba90050bee7622148032af7341ec;p=u-boot.git 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 Acked-by: Joe Hershberger Acked-by: Simon Glass Tested-by: Simon Glass --- diff --git a/net/eth.c b/net/eth.c index 6c490a6b93..18c53bf58a 100644 --- a/net/eth.c +++ b/net/eth.c @@ -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;