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 <j-keerthy@ti.com>
Signed-off-by: Lokesh Vutla <lokeshvutla@ti.com>
This commit is contained in:
Keerthy 2021-06-23 20:40:46 +05:30 committed by Praneeth Bajjuri
parent 51afd0146f
commit bad069367c
1 changed files with 8 additions and 3 deletions

View File

@ -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;
}