From bad069367cccb7cc349a652c015ec1bc67820879 Mon Sep 17 00:00:00 2001 From: Keerthy Date: Wed, 23 Jun 2021 20:40:46 +0530 Subject: [PATCH] net: eth-uclass: eth_get_dev based on SEQ_ALIAS instead of probe order In case of multiple eth interfaces currently eth_get_dev fetches the device based on the probe order which can be random hence try with the alias. Signed-off-by: Keerthy Signed-off-by: Lokesh Vutla --- net/eth-uclass.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/net/eth-uclass.c b/net/eth-uclass.c index e14695c0f1..e1b9fbd14a 100644 --- a/net/eth-uclass.c +++ b/net/eth-uclass.c @@ -78,9 +78,14 @@ struct udevice *eth_get_dev(void) if (!uc_priv) return NULL; - if (!uc_priv->current) - eth_errno = uclass_first_device(UCLASS_ETH, - &uc_priv->current); + if (!uc_priv->current) { + eth_errno = uclass_get_device_by_seq(UCLASS_ETH, 0, + &uc_priv->current); + if (eth_errno || !uc_priv->current) + eth_errno = uclass_first_device(UCLASS_ETH, + &uc_priv->current); + } + return uc_priv->current; }