net: cosmetic: Clean up cmd_net variables and functions

Make a thorough pass through all variables and function names contained
within common/cmd_net.c and remove CamelCase and improve naming.

Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Acked-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Joe Hershberger 2015-04-08 01:41:17 -05:00 committed by Simon Glass
parent 6a38a5f3df
commit 4fd5055f59
3 changed files with 32 additions and 33 deletions

View File

@ -157,15 +157,13 @@ static void netboot_update_env(void)
if (net_nis_domain[0]) if (net_nis_domain[0])
setenv("domain", net_nis_domain); setenv("domain", net_nis_domain);
#if defined(CONFIG_CMD_SNTP) \ #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_TIMEOFFSET)
&& defined(CONFIG_BOOTP_TIMEOFFSET)
if (NetTimeOffset) { if (NetTimeOffset) {
sprintf(tmp, "%d", NetTimeOffset); sprintf(tmp, "%d", NetTimeOffset);
setenv("timeoffset", tmp); setenv("timeoffset", tmp);
} }
#endif #endif
#if defined(CONFIG_CMD_SNTP) \ #if defined(CONFIG_CMD_SNTP) && defined(CONFIG_BOOTP_NTPSERVER)
&& defined(CONFIG_BOOTP_NTPSERVER)
if (net_ntp_server.s_addr) { if (net_ntp_server.s_addr) {
ip_to_string(net_ntp_server, tmp); ip_to_string(net_ntp_server, tmp);
setenv("ntpserverip", tmp); setenv("ntpserverip", tmp);
@ -183,9 +181,9 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
ulong addr; ulong addr;
/* pre-set load_addr */ /* pre-set load_addr */
if ((s = getenv("loadaddr")) != NULL) { s = getenv("loadaddr");
if (s != NULL)
load_addr = simple_strtoul(s, NULL, 16); load_addr = simple_strtoul(s, NULL, 16);
}
switch (argc) { switch (argc) {
case 1: case 1:
@ -205,7 +203,8 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
sizeof(net_boot_file_name)); sizeof(net_boot_file_name));
break; break;
case 3: load_addr = simple_strtoul(argv[1], NULL, 16); case 3:
load_addr = simple_strtoul(argv[1], NULL, 16);
copy_filename(net_boot_file_name, argv[2], copy_filename(net_boot_file_name, argv[2],
sizeof(net_boot_file_name)); sizeof(net_boot_file_name));
@ -214,7 +213,7 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
#ifdef CONFIG_CMD_TFTPPUT #ifdef CONFIG_CMD_TFTPPUT
case 4: case 4:
if (strict_strtoul(argv[1], 16, &save_addr) < 0 || if (strict_strtoul(argv[1], 16, &save_addr) < 0 ||
strict_strtoul(argv[2], 16, &save_size) < 0) { strict_strtoul(argv[2], 16, &save_size) < 0) {
printf("Invalid address/size\n"); printf("Invalid address/size\n");
return CMD_RET_USAGE; return CMD_RET_USAGE;
} }
@ -228,7 +227,8 @@ static int netboot_common(enum proto_t proto, cmd_tbl_t *cmdtp, int argc,
} }
bootstage_mark(BOOTSTAGE_ID_NET_START); bootstage_mark(BOOTSTAGE_ID_NET_START);
if ((size = NetLoop(proto)) < 0) { size = NetLoop(proto);
if (size < 0) {
bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK); bootstage_error(BOOTSTAGE_ID_NET_NETLOOP_OK);
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
} }
@ -293,18 +293,17 @@ static void cdp_update_env(void)
if (cdp_appliance_vlan != htons(-1)) { if (cdp_appliance_vlan != htons(-1)) {
printf("CDP offered appliance VLAN %d\n", printf("CDP offered appliance VLAN %d\n",
ntohs(cdp_appliance_vlan)); ntohs(cdp_appliance_vlan));
VLAN_to_string(cdp_appliance_vlan, tmp); vlan_to_string(cdp_appliance_vlan, tmp);
setenv("vlan", tmp); setenv("vlan", tmp);
NetOurVLAN = cdp_appliance_vlan; net_our_vlan = cdp_appliance_vlan;
} }
if (cdp_native_vlan != htons(-1)) { if (cdp_native_vlan != htons(-1)) {
printf("CDP offered native VLAN %d\n", ntohs(cdp_native_vlan)); printf("CDP offered native VLAN %d\n", ntohs(cdp_native_vlan));
VLAN_to_string(cdp_native_vlan, tmp); vlan_to_string(cdp_native_vlan, tmp);
setenv("nvlan", tmp); setenv("nvlan", tmp);
NetOurNativeVLAN = cdp_native_vlan; net_native_vlan = cdp_native_vlan;
} }
} }
int do_cdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) int do_cdp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@ -356,7 +355,7 @@ int do_sntp(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
if (NetLoop(SNTP) < 0) { if (NetLoop(SNTP) < 0) {
printf("SNTP failed: host %pI4 not responding\n", printf("SNTP failed: host %pI4 not responding\n",
&net_ntp_server); &net_ntp_server);
return CMD_RET_FAILURE; return CMD_RET_FAILURE;
} }

View File

@ -491,8 +491,8 @@ extern const u8 net_null_ethaddr[6];
#define VLAN_NONE 4095 /* untagged */ #define VLAN_NONE 4095 /* untagged */
#define VLAN_IDMASK 0x0fff /* mask of valid vlan id */ #define VLAN_IDMASK 0x0fff /* mask of valid vlan id */
extern ushort NetOurVLAN; /* Our VLAN */ extern ushort net_our_vlan; /* Our VLAN */
extern ushort NetOurNativeVLAN; /* Our Native VLAN */ extern ushort net_native_vlan; /* Our Native VLAN */
extern int NetRestartWrap; /* Tried all network devices */ extern int NetRestartWrap; /* Tried all network devices */
@ -791,13 +791,13 @@ void ip_to_string(struct in_addr x, char *s);
struct in_addr string_to_ip(const char *s); struct in_addr string_to_ip(const char *s);
/* Convert a VLAN id to a string */ /* Convert a VLAN id to a string */
void VLAN_to_string(ushort x, char *s); void vlan_to_string(ushort x, char *s);
/* Convert a string to a vlan id */ /* Convert a string to a vlan id */
ushort string_to_VLAN(const char *s); ushort string_to_vlan(const char *s);
/* read a VLAN id from an environment variable */ /* read a VLAN id from an environment variable */
ushort getenv_VLAN(char *); ushort getenv_vlan(char *);
/* copy a filename (allow for "..." notation, limit length) */ /* copy a filename (allow for "..." notation, limit length) */
void copy_filename(char *dst, const char *src, int size); void copy_filename(char *dst, const char *src, int size);

View File

@ -159,9 +159,9 @@ static int NetDevExists;
/* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */ /* XXX in both little & big endian machines 0xFFFF == ntohs(-1) */
/* default is without VLAN */ /* default is without VLAN */
ushort NetOurVLAN = 0xFFFF; ushort net_our_vlan = 0xFFFF;
/* ditto */ /* ditto */
ushort NetOurNativeVLAN = 0xFFFF; ushort net_native_vlan = 0xFFFF;
/* Boot File name */ /* Boot File name */
char net_boot_file_name[128]; char net_boot_file_name[128];
@ -261,8 +261,8 @@ static void NetInitLoop(void)
net_gateway = getenv_ip("gatewayip"); net_gateway = getenv_ip("gatewayip");
net_netmask = getenv_ip("netmask"); net_netmask = getenv_ip("netmask");
net_server_ip = getenv_ip("serverip"); net_server_ip = getenv_ip("serverip");
NetOurNativeVLAN = getenv_VLAN("nvlan"); net_native_vlan = getenv_vlan("nvlan");
NetOurVLAN = getenv_VLAN("vlan"); net_our_vlan = getenv_vlan("vlan");
#if defined(CONFIG_CMD_DNS) #if defined(CONFIG_CMD_DNS)
net_dns_server = getenv_ip("dnsip"); net_dns_server = getenv_ip("dnsip");
#endif #endif
@ -989,10 +989,10 @@ void net_process_received_packet(uchar *in_packet, int len)
iscdp = is_cdp_packet(et->et_dest); iscdp = is_cdp_packet(et->et_dest);
#endif #endif
myvlanid = ntohs(NetOurVLAN); myvlanid = ntohs(net_our_vlan);
if (myvlanid == (ushort)-1) if (myvlanid == (ushort)-1)
myvlanid = VLAN_NONE; myvlanid = VLAN_NONE;
mynvlanid = ntohs(NetOurNativeVLAN); mynvlanid = ntohs(net_native_vlan);
if (mynvlanid == (ushort)-1) if (mynvlanid == (ushort)-1)
mynvlanid = VLAN_NONE; mynvlanid = VLAN_NONE;
@ -1024,7 +1024,7 @@ void net_process_received_packet(uchar *in_packet, int len)
return; return;
/* if no VLAN active */ /* if no VLAN active */
if ((ntohs(NetOurVLAN) & VLAN_IDMASK) == VLAN_NONE if ((ntohs(net_our_vlan) & VLAN_IDMASK) == VLAN_NONE
#if defined(CONFIG_CMD_CDP) #if defined(CONFIG_CMD_CDP)
&& iscdp == 0 && iscdp == 0
#endif #endif
@ -1301,7 +1301,7 @@ net_eth_hdr_size(void)
{ {
ushort myvlanid; ushort myvlanid;
myvlanid = ntohs(NetOurVLAN); myvlanid = ntohs(net_our_vlan);
if (myvlanid == (ushort)-1) if (myvlanid == (ushort)-1)
myvlanid = VLAN_NONE; myvlanid = VLAN_NONE;
@ -1314,7 +1314,7 @@ int net_set_ether(uchar *xet, const uchar *dest_ethaddr, uint prot)
struct ethernet_hdr *et = (struct ethernet_hdr *)xet; struct ethernet_hdr *et = (struct ethernet_hdr *)xet;
ushort myvlanid; ushort myvlanid;
myvlanid = ntohs(NetOurVLAN); myvlanid = ntohs(net_our_vlan);
if (myvlanid == (ushort)-1) if (myvlanid == (ushort)-1)
myvlanid = VLAN_NONE; myvlanid = VLAN_NONE;
@ -1439,7 +1439,7 @@ void ip_to_string(struct in_addr x, char *s)
); );
} }
void VLAN_to_string(ushort x, char *s) void vlan_to_string(ushort x, char *s)
{ {
x = ntohs(x); x = ntohs(x);
@ -1452,7 +1452,7 @@ void VLAN_to_string(ushort x, char *s)
sprintf(s, "%d", x & VLAN_IDMASK); sprintf(s, "%d", x & VLAN_IDMASK);
} }
ushort string_to_VLAN(const char *s) ushort string_to_vlan(const char *s)
{ {
ushort id; ushort id;
@ -1467,7 +1467,7 @@ ushort string_to_VLAN(const char *s)
return htons(id); return htons(id);
} }
ushort getenv_VLAN(char *var) ushort getenv_vlan(char *var)
{ {
return string_to_VLAN(getenv(var)); return string_to_vlan(getenv(var));
} }