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

Joe Hershberger joe.hershberger at gmail.com
Tue Aug 25 20:55:38 CEST 2015


Hi Bin,

On Tue, Aug 25, 2015 at 2:22 AM, Bin Meng <bmeng.cn at 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 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
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot


More information about the U-Boot mailing list