[U-Boot] [PATCH v5 16/19] net: converted with new env interfaces
AKASHI Takahiro
takahiro.akashi at linaro.org
Thu Sep 5 08:21:30 UTC 2019
env_xxx(...) -> env_xxx(ctx_uboot, ...)
Signed-off-by: AKASHI Takahiro <takahiro.akashi at linaro.org>
---
net/bootp.c | 17 +++++++++--------
net/dns.c | 2 +-
net/eth-uclass.c | 6 +++---
net/eth_common.c | 18 +++++++++---------
net/eth_legacy.c | 2 +-
net/link_local.c | 2 +-
net/net.c | 11 ++++++-----
net/tftp.c | 10 +++++-----
net/wol.c | 2 +-
9 files changed, 36 insertions(+), 34 deletions(-)
diff --git a/net/bootp.c b/net/bootp.c
index 505489140e8a..3a9ca24e649f 100644
--- a/net/bootp.c
+++ b/net/bootp.c
@@ -176,7 +176,7 @@ static void store_net_params(struct bootp_hdr *bp)
* not contain a new value
*/
if (*net_boot_file_name)
- env_set("bootfile", net_boot_file_name);
+ env_set(ctx_uboot, "bootfile", net_boot_file_name);
#endif
net_copy_ip(&net_ip, &bp->bp_yiaddr);
}
@@ -395,7 +395,7 @@ static void bootp_timeout_handler(void)
#ifdef CONFIG_BOOTP_MAY_FAIL
char *ethrotate;
- ethrotate = env_get("ethrotate");
+ ethrotate = env_get(ctx_uboot, "ethrotate");
if ((ethrotate && strcmp(ethrotate, "no") == 0) ||
net_restart_wrap) {
puts("\nRetry time exceeded\n");
@@ -427,7 +427,7 @@ static void bootp_timeout_handler(void)
static u8 *add_vci(u8 *e)
{
char *vci = NULL;
- char *env_vci = env_get("bootp_vci");
+ char *env_vci = env_get(ctx_uboot, "bootp_vci");
#if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_NET_VCI_STRING)
vci = CONFIG_SPL_NET_VCI_STRING;
@@ -501,7 +501,7 @@ static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip,
*e++ = tmp & 0xff;
}
#if defined(CONFIG_BOOTP_SEND_HOSTNAME)
- hostname = env_get("hostname");
+ hostname = env_get(ctx_uboot, "hostname");
if (hostname) {
int hostnamelen = strlen(hostname);
@@ -516,8 +516,9 @@ static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip,
clientarch = CONFIG_BOOTP_PXE_CLIENTARCH;
#endif
- if (env_get("bootp_arch"))
- clientarch = env_get_ulong("bootp_arch", 16, clientarch);
+ if (env_get(ctx_uboot, "bootp_arch"))
+ clientarch = env_get_ulong(ctx_uboot, "bootp_arch", 16,
+ clientarch);
if (clientarch > 0) {
*e++ = 93; /* Client System Architecture */
@@ -533,7 +534,7 @@ static int dhcp_extended(u8 *e, int message_type, struct in_addr server_ip,
*e++ = 0; /* minor revision */
#ifdef CONFIG_LIB_UUID
- uuid = env_get("pxeuuid");
+ uuid = env_get(ctx_uboot, "pxeuuid");
if (uuid) {
if (uuid_str_valid(uuid)) {
@@ -726,7 +727,7 @@ void bootp_request(void)
dhcp_state = INIT;
#endif
- ep = env_get("bootpretryperiod");
+ ep = env_get(ctx_uboot, "bootpretryperiod");
if (ep != NULL)
time_taken_max = simple_strtoul(ep, NULL, 10);
else
diff --git a/net/dns.c b/net/dns.c
index 67d761d7c0f5..93e338e9cb22 100644
--- a/net/dns.c
+++ b/net/dns.c
@@ -185,7 +185,7 @@ static void dns_handler(uchar *pkt, unsigned dest, struct in_addr sip,
ip_to_string(ip_addr, ip_str);
printf("%s\n", ip_str);
if (net_dns_env_var)
- env_set(net_dns_env_var, ip_str);
+ env_set(ctx_uboot, net_dns_env_var, ip_str);
} else {
puts("server responded with invalid IP number\n");
}
diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 1d5d2f03b7d9..d7bec3377e6f 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -240,8 +240,8 @@ U_BOOT_ENV_CALLBACK(ethaddr, on_ethaddr);
int eth_init(void)
{
- char *ethact = env_get("ethact");
- char *ethrotate = env_get("ethrotate");
+ char *ethact = env_get(ctx_uboot, "ethact");
+ char *ethrotate = env_get(ctx_uboot, "ethrotate");
struct udevice *current = NULL;
struct udevice *old_current;
int ret = -ENODEV;
@@ -401,7 +401,7 @@ int eth_initialize(void)
printf("No ethernet found.\n");
bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
} else {
- char *ethprime = env_get("ethprime");
+ char *ethprime = env_get(ctx_uboot, "ethprime");
struct udevice *prime_dev = NULL;
if (ethprime)
diff --git a/net/eth_common.c b/net/eth_common.c
index ed26b1b69359..f845601a13b0 100644
--- a/net/eth_common.c
+++ b/net/eth_common.c
@@ -46,13 +46,13 @@ int eth_mac_skip(int index)
char *skip_state;
sprintf(enetvar, index ? "eth%dmacskip" : "ethmacskip", index);
- skip_state = env_get(enetvar);
+ skip_state = env_get(ctx_uboot, enetvar);
return skip_state != NULL;
}
void eth_current_changed(void)
{
- char *act = env_get("ethact");
+ char *act = env_get(ctx_uboot, "ethact");
char *ethrotate;
/*
@@ -60,21 +60,21 @@ void eth_current_changed(void)
* ethernet device if uc_priv->current == NULL. This is not what
* we want when 'ethrotate' variable is 'no'.
*/
- ethrotate = env_get("ethrotate");
+ ethrotate = env_get(ctx_uboot, "ethrotate");
if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0))
return;
/* update current ethernet name */
if (eth_get_dev()) {
if (act == NULL || strcmp(act, eth_get_name()) != 0)
- env_set("ethact", eth_get_name());
+ env_set(ctx_uboot, "ethact", eth_get_name());
}
/*
* remove the variable completely if there is no active
* interface
*/
else if (act != NULL)
- env_set("ethact", NULL);
+ env_set(ctx_uboot, "ethact", NULL);
}
void eth_try_another(int first_restart)
@@ -86,7 +86,7 @@ void eth_try_another(int first_restart)
* Do not rotate between network interfaces when
* 'ethrotate' variable is set to 'no'.
*/
- ethrotate = env_get("ethrotate");
+ ethrotate = env_get(ctx_uboot, "ethrotate");
if ((ethrotate != NULL) && (strcmp(ethrotate, "no") == 0))
return;
@@ -110,14 +110,14 @@ void eth_set_current(void)
static int env_changed_id;
int env_id;
- env_id = env_get_id();
+ env_id = env_get_id(ctx_uboot);
if ((act == NULL) || (env_changed_id != env_id)) {
- act = env_get("ethact");
+ act = env_get(ctx_uboot, "ethact");
env_changed_id = env_id;
}
if (act == NULL) {
- char *ethprime = env_get("ethprime");
+ char *ethprime = env_get(ctx_uboot, "ethprime");
void *dev = NULL;
if (ethprime)
diff --git a/net/eth_legacy.c b/net/eth_legacy.c
index 850f362d873e..a166244e18bf 100644
--- a/net/eth_legacy.c
+++ b/net/eth_legacy.c
@@ -260,7 +260,7 @@ int eth_initialize(void)
bootstage_error(BOOTSTAGE_ID_NET_ETH_START);
} else {
struct eth_device *dev = eth_devices;
- char *ethprime = env_get("ethprime");
+ char *ethprime = env_get(ctx_uboot, "ethprime");
bootstage_mark(BOOTSTAGE_ID_NET_ETH_INIT);
do {
diff --git a/net/link_local.c b/net/link_local.c
index dd9fcad0874d..c0adc583fb71 100644
--- a/net/link_local.c
+++ b/net/link_local.c
@@ -105,7 +105,7 @@ static void configure_wait(void)
void link_local_start(void)
{
- ip = env_get_ip("llipaddr");
+ ip = env_get_ip(ctx_uboot, "llipaddr");
if (ip.s_addr != 0 &&
(ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR) {
puts("invalid link address");
diff --git a/net/net.c b/net/net.c
index 40511db645df..92e3c9fa8016 100644
--- a/net/net.c
+++ b/net/net.c
@@ -306,7 +306,7 @@ U_BOOT_ENV_CALLBACK(dnsip, on_dnsip);
void net_auto_load(void)
{
#if defined(CONFIG_CMD_NFS)
- const char *s = env_get("autoload");
+ const char *s = env_get(ctx_uboot, "autoload");
if (s != NULL && strcmp(s, "NFS") == 0) {
if (net_check_prereq(NFS)) {
@@ -635,8 +635,9 @@ restart:
if (net_boot_file_size > 0) {
printf("Bytes transferred = %d (%x hex)\n",
net_boot_file_size, net_boot_file_size);
- env_set_hex("filesize", net_boot_file_size);
- env_set_hex("fileaddr", load_addr);
+ env_set_hex(ctx_uboot, "filesize",
+ net_boot_file_size);
+ env_set_hex(ctx_uboot, "fileaddr", load_addr);
}
if (protocol != NETCONS)
eth_halt();
@@ -689,7 +690,7 @@ int net_start_again(void)
unsigned long retrycnt = 0;
int ret;
- nretry = env_get("netretry");
+ nretry = env_get(ctx_uboot, "netretry");
if (nretry) {
if (!strcmp(nretry, "yes"))
retry_forever = 1;
@@ -1612,7 +1613,7 @@ ushort string_to_vlan(const char *s)
ushort env_get_vlan(char *var)
{
- return string_to_vlan(env_get(var));
+ return string_to_vlan(env_get(ctx_uboot, var));
}
void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr)
diff --git a/net/tftp.c b/net/tftp.c
index 5a69bca6413c..452628dd7f8c 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -629,11 +629,11 @@ void tftp_start(enum proto_t protocol)
* TFTP protocol has a minimal timeout of 1 second.
*/
- ep = env_get("tftpblocksize");
+ ep = env_get(ctx_uboot, "tftpblocksize");
if (ep != NULL)
tftp_block_size_option = simple_strtol(ep, NULL, 10);
- ep = env_get("tftptimeout");
+ ep = env_get(ctx_uboot, "tftptimeout");
if (ep != NULL)
timeout_ms = simple_strtol(ep, NULL, 10);
@@ -643,7 +643,7 @@ void tftp_start(enum proto_t protocol)
timeout_ms = 1000;
}
- ep = env_get("tftptimeoutcountmax");
+ ep = env_get(ctx_uboot, "tftptimeoutcountmax");
if (ep != NULL)
tftp_timeout_count_max = simple_strtol(ep, NULL, 10);
@@ -743,10 +743,10 @@ void tftp_start(enum proto_t protocol)
tftp_our_port = 1024 + (get_timer(0) % 3072);
#ifdef CONFIG_TFTP_PORT
- ep = env_get("tftpdstp");
+ ep = env_get(ctx_uboot, "tftpdstp");
if (ep != NULL)
tftp_remote_port = simple_strtol(ep, NULL, 10);
- ep = env_get("tftpsrcp");
+ ep = env_get(ctx_uboot, "tftpsrcp");
if (ep != NULL)
tftp_our_port = simple_strtol(ep, NULL, 10);
#endif
diff --git a/net/wol.c b/net/wol.c
index 0a625668a992..9afd7149f34c 100644
--- a/net/wol.c
+++ b/net/wol.c
@@ -56,7 +56,7 @@ void wol_receive(struct ip_udp_hdr *ip, unsigned int len)
struct in_addr *ip = (struct in_addr *)(wol->wol_passwd);
ip_to_string(*ip, buffer);
- env_set("wolpassword", buffer);
+ env_set(ctx_uboot, "wolpassword", buffer);
}
net_set_state(NETLOOP_SUCCESS);
}
--
2.21.0
More information about the U-Boot
mailing list