allow changing of network device
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
parent
f090bca2d8
commit
53488058e6
|
@ -275,3 +275,41 @@ U_BOOT_CMD_START(cdp)
|
||||||
U_BOOT_CMD_END
|
U_BOOT_CMD_END
|
||||||
|
|
||||||
#endif /* CONFIG_NET_CDP */
|
#endif /* CONFIG_NET_CDP */
|
||||||
|
|
||||||
|
static int do_ethact (cmd_tbl_t *cmdtp, int argc, char *argv[])
|
||||||
|
{
|
||||||
|
struct device_d *dev;
|
||||||
|
struct eth_device *edev;
|
||||||
|
|
||||||
|
if (argc != 2) {
|
||||||
|
u_boot_cmd_usage(cmdtp);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
dev = get_device_by_path(argv[1]);
|
||||||
|
if (!dev) {
|
||||||
|
perror("open");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (dev->type != DEVICE_TYPE_ETHER) {
|
||||||
|
printf("nat a net device: %s\n", argv[1]);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
edev = dev->type_data;
|
||||||
|
eth_set_current(edev);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const __maybe_unused char cmd_ethact_help[] =
|
||||||
|
"Usage: ethact /dev/ethx\n";
|
||||||
|
|
||||||
|
U_BOOT_CMD_START(ethact)
|
||||||
|
.maxargs = 3,
|
||||||
|
.cmd = do_ethact,
|
||||||
|
.usage = "set current ethernet device",
|
||||||
|
U_BOOT_CMD_HELP(cmd_ethact_help)
|
||||||
|
U_BOOT_CMD_END
|
||||||
|
|
||||||
|
|
|
@ -118,6 +118,8 @@ int eth_register(struct eth_device *edev)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dev->type_data = edev;
|
||||||
|
dev->type = DEVICE_TYPE_ETHER;
|
||||||
edev->param_ip.name = "ipaddr";
|
edev->param_ip.name = "ipaddr";
|
||||||
edev->param_ip.set = ð_set_ipaddr;
|
edev->param_ip.set = ð_set_ipaddr;
|
||||||
edev->param_ethaddr.name = "ethaddr";
|
edev->param_ethaddr.name = "ethaddr";
|
||||||
|
@ -142,7 +144,8 @@ int eth_register(struct eth_device *edev)
|
||||||
dev_set_param(dev, "ethaddr", ethaddr_str);
|
dev_set_param(dev, "ethaddr", ethaddr_str);
|
||||||
}
|
}
|
||||||
|
|
||||||
eth_current = edev;
|
if (!eth_current)
|
||||||
|
eth_current = edev;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue