diff mbox

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

Message ID 1440487347-10517-4-git-send-email-bmeng.cn@gmail.com
State Superseded
Delegated to: Simon Glass
Headers show

Commit Message

Bin Meng Aug. 25, 2015, 7:22 a.m. UTC
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@gmail.com>

---

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

Comments

Joe Hershberger Aug. 25, 2015, 6:55 p.m. UTC | #1
Hi Bin,

On Tue, Aug 25, 2015 at 2:22 AM, Bin Meng <bmeng.cn@gmail.com> wrote:
> 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).

I believe there is a test for this (dm_test_eth_rotate). Apparently it
is not a sufficient test. Please describe the way in which this
behavior is broken and add a test case to test/dm/eth.c that would
fail without your change.

> Signed-off-by: Bin Meng <bmeng.cn@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
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
diff mbox

Patch

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