diff mbox series

[U-Boot,v4,13/42] common: Move env_get_ip() to net.h

Message ID 20191114125724.v4.13.I6da24bfbaae4b2e00bb4f86b6ed687e364f02c3d@changeid
State Accepted
Commit 8d5babb45a051efb9ce4c9e06a693d72ee6cba5a
Delegated to: Tom Rini
Headers show
Series common: Further reduce common.h | expand

Commit Message

Simon Glass Nov. 14, 2019, 7:57 p.m. UTC
This function relates to networking, so move it out of the common.h
header file.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
---

Changes in v4: None
Changes in v3: None
Changes in v2: None

 include/common.h |  4 ----
 include/net.h    | 21 ++++++++++++++++++++-
 2 files changed, 20 insertions(+), 5 deletions(-)

Comments

Joe Hershberger Nov. 18, 2019, 9:27 p.m. UTC | #1
On Thu, Nov 14, 2019 at 2:05 PM Simon Glass <sjg@chromium.org> wrote:
>
> This function relates to networking, so move it out of the common.h
> header file.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Nit below, but...

Acked-by: Joe Hershberger <joe.hershberger@ni.com>

> ---
>
> Changes in v4: None
> Changes in v3: None
> Changes in v2: None
>
>  include/common.h |  4 ----
>  include/net.h    | 21 ++++++++++++++++++++-
>  2 files changed, 20 insertions(+), 5 deletions(-)
>
> diff --git a/include/common.h b/include/common.h
> index f993e4bef3..4fda40cc1d 100644
> --- a/include/common.h
> +++ b/include/common.h
> @@ -319,10 +319,6 @@ int        serial_printf (const char *fmt, ...)
>
>  /* lib/net_utils.c */
>  #include <net.h>
> -static inline struct in_addr env_get_ip(char *var)
> -{
> -       return string_to_ip(env_get(var));
> -}
>
>  #include <bootstage.h>
>
> diff --git a/include/net.h b/include/net.h
> index d8d187d8af..11eca1bc6c 100644
> --- a/include/net.h
> +++ b/include/net.h
> @@ -829,7 +829,13 @@ static inline void net_random_ethaddr(uchar *addr)
>  /* Convert an IP address to a string */
>  void ip_to_string(struct in_addr x, char *s);
>
> -/* Convert a string to ip address */
> +/**
> + * string_to_ip() - Convert a string to ip address
> + *
> + * @s: String to conver, in the format format a.b.c.d, where each value is a
> + *     decimal number from 0 to 255
> + * @return IP address, or 0 if invalid
> + */

Please drop this unrelated documentation update... it conflicts with [1]

[1] - https://patchwork.ozlabs.org/patch/1162279/

>  struct in_addr string_to_ip(const char *s);
>
>  /* Convert a VLAN id to a string */
> @@ -887,4 +893,17 @@ int update_tftp(ulong addr, char *interface, char *devstring);
>   */
>  void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr);
>
> +/**
> + * env_get_ip() - Convert an environment value to to an ip address
> + *
> + * @var: Environment variable to convert. The value of this variable must be
> + *     in the format format a.b.c.d, where each value is a decimal number from
> + *     0 to 255
> + * @return IP address, or 0 if invalid
> + */
> +static inline struct in_addr env_get_ip(char *var)
> +{
> +       return string_to_ip(env_get(var));
> +}
> +
>  #endif /* __NET_H__ */
> --
> 2.24.0.rc1.363.gb1bccd3e3d-goog
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> https://lists.denx.de/listinfo/u-boot
diff mbox series

Patch

diff --git a/include/common.h b/include/common.h
index f993e4bef3..4fda40cc1d 100644
--- a/include/common.h
+++ b/include/common.h
@@ -319,10 +319,6 @@  int	serial_printf (const char *fmt, ...)
 
 /* lib/net_utils.c */
 #include <net.h>
-static inline struct in_addr env_get_ip(char *var)
-{
-	return string_to_ip(env_get(var));
-}
 
 #include <bootstage.h>
 
diff --git a/include/net.h b/include/net.h
index d8d187d8af..11eca1bc6c 100644
--- a/include/net.h
+++ b/include/net.h
@@ -829,7 +829,13 @@  static inline void net_random_ethaddr(uchar *addr)
 /* Convert an IP address to a string */
 void ip_to_string(struct in_addr x, char *s);
 
-/* Convert a string to ip address */
+/**
+ * string_to_ip() - Convert a string to ip address
+ *
+ * @s: String to conver, in the format format a.b.c.d, where each value is a
+ *	decimal number from 0 to 255
+ * @return IP address, or 0 if invalid
+ */
 struct in_addr string_to_ip(const char *s);
 
 /* Convert a VLAN id to a string */
@@ -887,4 +893,17 @@  int update_tftp(ulong addr, char *interface, char *devstring);
  */
 void eth_parse_enetaddr(const char *addr, uint8_t *enetaddr);
 
+/**
+ * env_get_ip() - Convert an environment value to to an ip address
+ *
+ * @var: Environment variable to convert. The value of this variable must be
+ *	in the format format a.b.c.d, where each value is a decimal number from
+ *	0 to 255
+ * @return IP address, or 0 if invalid
+ */
+static inline struct in_addr env_get_ip(char *var)
+{
+	return string_to_ip(env_get(var));
+}
+
 #endif /* __NET_H__ */