diff mbox series

[v2,01/10] net: eth-uclass: eth_get_dev based on SEQ_ALIAS instead of probe order

Message ID 20200218051004.32524-2-j-keerthy@ti.com
State New
Headers show
Series net: ti: icssg: Add prueth support | expand

Commit Message

J, KEERTHY Feb. 18, 2020, 5:09 a.m. UTC
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 at ti.com>
---

Changes in v2:

  * Fixed comments from Tom & Lokesh as per:
    https://patchwork.ozlabs.org/patch/1142697/

 net/eth-uclass.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

Comments

Simon Glass Feb. 18, 2020, 6:31 p.m. UTC | #1
Hi Keerthy,

On Mon, 17 Feb 2020 at 22:10, Keerthy <j-keerthy at ti.com> wrote:
>
> 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 at ti.com>
> ---
>
> Changes in v2:
>
>   * Fixed comments from Tom & Lokesh as per:
>     https://patchwork.ozlabs.org/patch/1142697/
>
>  net/eth-uclass.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)

This one is for Joe to review.

But please do add/update the network tests to cover this behaviour.

Regards,
Simon
diff mbox series

Patch

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index ed81cbd537..93855e933b 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -68,9 +68,15 @@  struct udevice *eth_get_dev(void)
 	struct eth_uclass_priv *uc_priv;
 
 	uc_priv = eth_get_uclass_priv();
-	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;
 }