dm: eth: Correctly detect alias in eth_get_dev_by_name()
When given a device name string, we should test to see if it is really an alias like "eth#". Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
This commit is contained in:
parent
71d7971fac
commit
e408c42189
@ -195,10 +195,11 @@ struct udevice *eth_get_dev_by_name(const char *devname)
|
||||
const char *startp = NULL;
|
||||
struct udevice *it;
|
||||
struct uclass *uc;
|
||||
int len = strlen("eth");
|
||||
|
||||
/* Must be longer than 3 to be an alias */
|
||||
if (strlen(devname) > strlen("eth")) {
|
||||
startp = devname + strlen("eth");
|
||||
if (!strncmp(devname, "eth", len) && strlen(devname) > len) {
|
||||
startp = devname + len;
|
||||
seq = simple_strtoul(startp, &endp, 10);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user