TFTPGET
};
-void net_lwip_set_current(void);
+static inline int eth_is_on_demand_init(void)
+{
+ return 1;
+}
+
+int eth_init_state_only(void); /* Set active state */
+
+int net_lwip_eth_start(void);
struct netif *net_lwip_new_netif(struct udevice *udev);
struct netif *net_lwip_new_netif_noip(struct udevice *udev);
void net_lwip_remove_netif(struct netif *netif);
int ret;
struct udevice *dev;
- net_lwip_set_current();
+ if (net_lwip_eth_start() < 0)
+ return CMD_RET_FAILURE;
dev = eth_get_dev();
if (!dev) {
if (argc == 3)
var = argv[2];
- net_lwip_set_current();
+ if (net_lwip_eth_start() < 0)
+ return CMD_RET_FAILURE;
return dns_loop(eth_get_dev(), name, var);
}
return 0;
}
-/* Initialize the lwIP stack and the ethernet devices and set current device */
-void net_lwip_set_current(void)
+/*
+ * Initialize the network stack if needed and start the current device if valid
+ */
+int net_lwip_eth_start(void)
{
- static bool init_done;
-
- if (!init_done) {
- eth_init_rings();
- eth_init();
- lwip_init();
- init_done = true;
+ int ret;
+
+ net_init();
+ if (eth_is_on_demand_init()) {
+ eth_halt();
+ eth_set_current();
+ ret = eth_init();
+ if (ret < 0) {
+ eth_halt();
+ return ret;
+ }
+ } else {
+ eth_init_state_only();
}
- eth_set_current();
+
+ return 0;
}
static struct netif *new_netif(struct udevice *udev, bool with_ip)
free(netif);
}
+/*
+ * Initialize the network buffers, an ethernet device, and the lwIP stack
+ * (once).
+ */
int net_init(void)
{
- eth_set_current();
+ static bool init_done;
- net_lwip_new_netif(eth_get_dev());
+ if (!init_done) {
+ eth_init_rings();
+ eth_init();
+ lwip_init();
+ init_done = true;
+ }
return 0;
}
if (!ipaddr_aton(argv[1], &addr))
return CMD_RET_USAGE;
- net_lwip_set_current();
+ if (net_lwip_eth_start() < 0)
+ return CMD_RET_FAILURE;
if (ping_loop(eth_get_dev(), &addr) < 0)
return CMD_RET_FAILURE;
goto out;
}
- net_lwip_set_current();
+ if (net_lwip_eth_start() < 0) {
+ ret = CMD_RET_FAILURE;
+ goto out;
+ }
if (tftp_loop(eth_get_dev(), laddr, fname, srvip, port) < 0)
ret = CMD_RET_FAILURE;
int wget_do_request(ulong dst_addr, char *uri)
{
- net_lwip_set_current();
+ int ret;
+
+ ret = net_lwip_eth_start();
+ if (ret < 0)
+ return ret;
if (!wget_info)
wget_info = &default_wget_info;