From e58780dcb7b8656ebc2dd6ba6d0da728bc65bf40 Mon Sep 17 00:00:00 2001 From: Joe Hershberger Date: Sun, 22 Mar 2015 17:09:16 -0500 Subject: dm: eth: Add support for aliases Allow network devices to be referred to as "eth0" instead of "eth@12345678" when specified in ethact. Add tests to verify this behavior. Signed-off-by: Joe Hershberger Reviewed-by: Simon Glass --- test/dm/eth.c | 24 ++++++++++++++++++++++++ test/dm/test.dts | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/test/dm/eth.c b/test/dm/eth.c index 04ccf49820..5688b71de0 100644 --- a/test/dm/eth.c +++ b/test/dm/eth.c @@ -36,3 +36,27 @@ static int dm_test_eth(struct dm_test_state *dms) return 0; } DM_TEST(dm_test_eth, DM_TESTF_SCAN_FDT); + +static int dm_test_eth_alias(struct dm_test_state *dms) +{ + NetPingIP = string_to_ip("1.1.2.2"); + setenv("ethact", "eth0"); + ut_assertok(NetLoop(PING)); + ut_asserteq_str("eth@10002000", getenv("ethact")); + + setenv("ethact", "eth1"); + ut_assertok(NetLoop(PING)); + ut_asserteq_str("eth@10004000", getenv("ethact")); + + /* Expected to fail since eth2 is not defined in the device tree */ + setenv("ethact", "eth2"); + ut_assertok(NetLoop(PING)); + ut_asserteq_str("eth@10002000", getenv("ethact")); + + setenv("ethact", "eth5"); + ut_assertok(NetLoop(PING)); + ut_asserteq_str("eth@10003000", getenv("ethact")); + + return 0; +} +DM_TEST(dm_test_eth_alias, DM_TESTF_SCAN_FDT); diff --git a/test/dm/test.dts b/test/dm/test.dts index 762ddc3507..0ab0916858 100644 --- a/test/dm/test.dts +++ b/test/dm/test.dts @@ -18,6 +18,8 @@ testfdt3 = "/b-test"; testfdt5 = "/some-bus/c-test@5"; testfdt8 = "/a-test"; + eth0 = "/eth@10002000"; + eth5 = ð_5; }; uart0: serial { @@ -172,7 +174,7 @@ fake-host-hwaddr = <0x00 0x00 0x66 0x44 0x22 0x00>; }; - eth@10003000 { + eth_5: eth@10003000 { compatible = "sandbox,eth"; reg = <0x10003000 0x1000>; fake-host-hwaddr = <0x00 0x00 0x66 0x44 0x22 0x11>; -- cgit v1.2.1