diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2018-07-02 14:47:52 -0500 |
---|---|---|
committer | Joe Hershberger <joe.hershberger@ni.com> | 2018-07-26 14:08:18 -0500 |
commit | c9e2caff8503b0dfa750b5ed08f882919fd3b510 (patch) | |
tree | 37c9f94265e4fe0be0a8cec139cb42b9b18f0df3 /drivers/net/sandbox-raw.c | |
parent | ac13270b49d55677aeea5a64dfbf1764118820e3 (diff) |
sandbox: eth-raw: Allow interface to be specified by index
With systemd stable interface names, eth0 will almost never exist.
Instead of using that name in the sandbox.dts, use an index.
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers/net/sandbox-raw.c')
-rw-r--r-- | drivers/net/sandbox-raw.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c index c04b94c6e18..0d1fd4d9311 100644 --- a/drivers/net/sandbox-raw.c +++ b/drivers/net/sandbox-raw.c @@ -143,6 +143,7 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev) struct eth_sandbox_raw_priv *priv = dev_get_priv(dev); const char *ifname; u32 local; + int ret; pdata->iobase = dev_read_addr(dev); @@ -151,6 +152,16 @@ static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev) strncpy(priv->host_ifname, ifname, IFNAMSIZ); printf(": Using %s from DT\n", priv->host_ifname); } + if (dev_read_u32(dev, "host-raw-interface-idx", + &priv->host_ifindex) < 0) { + priv->host_ifindex = 0; + } else { + ret = sandbox_eth_raw_os_idx_to_name(priv); + if (ret < 0) + return ret; + printf(": Using interface index %d from DT (%s)\n", + priv->host_ifindex, priv->host_ifname); + } local = sandbox_eth_raw_os_is_local(priv->host_ifname); if (local < 0) |