[U-Boot] [PATCH 4/9] dm: eth: Correctly detect alias in eth_get_dev_by_name()

Bin Meng bmeng.cn at gmail.com
Tue Aug 25 09:22:22 CEST 2015


When given a device name string, we should test if it contains "eth"
before we treat it as an alias.

With this commit, now we are really able to rotate between network
interfaces with driver model (previously it was broken).

Signed-off-by: Bin Meng <bmeng.cn at gmail.com>

---

 net/eth.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/eth.c b/net/eth.c
index 0b4b08a..fbf30b0 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -197,7 +197,7 @@ struct udevice *eth_get_dev_by_name(const char *devname)
 	struct uclass *uc;
 
 	/* Must be longer than 3 to be an alias */
-	if (strlen(devname) > strlen("eth")) {
+	if (strstr(devname, "eth") && strlen(devname) > strlen("eth")) {
 		startp = devname + strlen("eth");
 		seq = simple_strtoul(startp, &endp, 10);
 	}
-- 
1.8.2.1



More information about the U-Boot mailing list