diff options
author | Joe Hershberger <joe.hershberger@ni.com> | 2018-07-02 14:47:50 -0500 |
---|---|---|
committer | Joe Hershberger <joe.hershberger@ni.com> | 2018-07-26 14:08:18 -0500 |
commit | 8c7988b6dbfb0aa05a935e602b8cdb67f7dd60b2 (patch) | |
tree | 834fd412568af06032929d8185037b84f3573a45 /drivers | |
parent | b32dd183c2d50d897e6ec736ddb3ada0563b9243 (diff) |
net: sandbox-raw: Convert raw eth driver to livetree
Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/sandbox-raw.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/drivers/net/sandbox-raw.c b/drivers/net/sandbox-raw.c index 3f8020f629..317e964019 100644 --- a/drivers/net/sandbox-raw.c +++ b/drivers/net/sandbox-raw.c @@ -21,21 +21,16 @@ static int sb_eth_raw_start(struct udevice *dev) { struct eth_sandbox_raw_priv *priv = dev_get_priv(dev); struct eth_pdata *pdata = dev_get_platdata(dev); - const char *interface; + int ret; debug("eth_sandbox_raw: Start\n"); - interface = fdt_getprop(gd->fdt_blob, dev_of_offset(dev), - "host-raw-interface", NULL); - if (interface == NULL) - return -EINVAL; - - if (strcmp(interface, "lo") == 0) { - priv->local = 1; + ret = sandbox_eth_raw_os_start(priv, pdata->enetaddr); + if (priv->local) { env_set("ipaddr", "127.0.0.1"); env_set("serverip", "127.0.0.1"); } - return sandbox_eth_raw_os_start(interface, pdata->enetaddr, priv); + return ret; } static int sb_eth_raw_send(struct udevice *dev, void *packet, int length) @@ -143,8 +138,19 @@ static const struct eth_ops sb_eth_raw_ops = { static int sb_eth_raw_ofdata_to_platdata(struct udevice *dev) { struct eth_pdata *pdata = dev_get_platdata(dev); + struct eth_sandbox_raw_priv *priv = dev_get_priv(dev); + const char *ifname; + + pdata->iobase = dev_read_addr(dev); + + ifname = dev_read_string(dev, "host-raw-interface"); + if (ifname) { + strncpy(priv->host_ifname, ifname, IFNAMSIZ); + printf(": Using %s from DT\n", priv->host_ifname); + if (strcmp(ifname, "lo") == 0) + priv->local = 1; + } - pdata->iobase = devfdt_get_addr(dev); return 0; } |