[U-Boot] [PATCH v1 5/5] net: Avoid build fail on am335x when NET is disabled
Joe Hershberger
joe.hershberger at ni.com
Thu Mar 29 15:53:04 UTC 2018
On Thu, Mar 29, 2018 at 10:17 AM, Alex Kiernan <alex.kiernan at gmail.com> wrote:
> Commit f411b5cca48f ("board: am335x: Always set eth/eth1addr environment
> variable") adds support for Ethernet in Linux, but not U-Boot.
>
> Ensure that we can do this even when U-Boot is compiled without
> network support.
Please improve this commit log. It should have a subject that says
what it does (Move enetaddr env access code to env config instead of
net config) Then talk about why you are doing it in the body (i.e. the
current subject).
>
> Signed-off-by: Alex Kiernan <alex.kiernan at gmail.com>
> ---
>
> cmd/nvedit.c | 30 ++++++++++++++++++++++++++++++
> include/common.h | 4 ++++
> include/net.h | 3 ---
> net/eth_common.c | 30 ------------------------------
> 4 files changed, 34 insertions(+), 33 deletions(-)
>
> diff --git a/cmd/nvedit.c b/cmd/nvedit.c
> index 4cb25b8..4008de1 100644
> --- a/cmd/nvedit.c
> +++ b/cmd/nvedit.c
> @@ -341,6 +341,36 @@ ulong env_get_hex(const char *varname, ulong default_val)
> return value;
> }
>
> +void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
> +{
> + char *end;
> + int i;
> +
> + for (i = 0; i < 6; ++i) {
> + enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
> + if (addr)
> + addr = (*end) ? end + 1 : end;
> + }
> +}
> +
> +int eth_env_get_enetaddr(const char *name, uchar *enetaddr)
> +{
> + eth_parse_enetaddr(env_get(name), enetaddr);
> + return is_valid_ethaddr(enetaddr);
> +}
> +
> +int eth_env_set_enetaddr(const char *name, const uchar *enetaddr)
> +{
> + char buf[ARP_HLEN_ASCII + 1];
> +
> + if (eth_env_get_enetaddr(name, (uchar *)buf))
> + return -EEXIST;
> +
> + sprintf(buf, "%pM", enetaddr);
> +
> + return env_set(name, buf);
> +}
> +
> #ifndef CONFIG_SPL_BUILD
> static int do_env_set(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
> {
> diff --git a/include/common.h b/include/common.h
> index 3087505..b7280eb 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -243,6 +243,10 @@ static inline int env_set_addr(const char *varname, const void *addr)
> return env_set_hex(varname, (ulong)addr);
> }
>
> +void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
> +int eth_env_get_enetaddr(const char *name, uchar *enetaddr);
> +int eth_env_set_enetaddr(const char *name, const uchar *enetaddr);
Please move this to include/environment.h
> +
> #ifdef CONFIG_AUTO_COMPLETE
> int env_complete(char *var, int maxv, char *cmdv[], int maxsz, char *buf);
> #endif
> diff --git a/include/net.h b/include/net.h
> index 455b48f..c339b9d 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -238,9 +238,6 @@ void eth_try_another(int first_restart); /* Change the device */
> void eth_set_current(void); /* set nterface to ethcur var */
>
> int eth_get_dev_index(void); /* get the device index */
> -void eth_parse_enetaddr(const char *addr, uchar *enetaddr);
> -int eth_env_get_enetaddr(const char *name, uchar *enetaddr);
> -int eth_env_set_enetaddr(const char *name, const uchar *enetaddr);
>
> /**
> * eth_env_set_enetaddr_by_index() - set the MAC address environment variable
> diff --git a/net/eth_common.c b/net/eth_common.c
> index 66d0d22..cb7f029 100644
> --- a/net/eth_common.c
> +++ b/net/eth_common.c
> @@ -12,36 +12,6 @@
> #include <net.h>
> #include "eth_internal.h"
>
> -void eth_parse_enetaddr(const char *addr, uchar *enetaddr)
> -{
> - char *end;
> - int i;
> -
> - for (i = 0; i < 6; ++i) {
> - enetaddr[i] = addr ? simple_strtoul(addr, &end, 16) : 0;
> - if (addr)
> - addr = (*end) ? end + 1 : end;
> - }
> -}
> -
> -int eth_env_get_enetaddr(const char *name, uchar *enetaddr)
> -{
> - eth_parse_enetaddr(env_get(name), enetaddr);
> - return is_valid_ethaddr(enetaddr);
> -}
> -
> -int eth_env_set_enetaddr(const char *name, const uchar *enetaddr)
> -{
> - char buf[ARP_HLEN_ASCII + 1];
> -
> - if (eth_env_get_enetaddr(name, (uchar *)buf))
> - return -EEXIST;
> -
> - sprintf(buf, "%pM", enetaddr);
> -
> - return env_set(name, buf);
> -}
> -
> int eth_env_get_enetaddr_by_index(const char *base_name, int index,
> uchar *enetaddr)
> {
> --
> 2.7.4
>
> _______________________________________________
> U-Boot mailing list
> U-Boot at lists.denx.de
> https://lists.denx.de/listinfo/u-boot
More information about the U-Boot
mailing list