From patchwork Fri Nov 8 19:53:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1192138 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="lW+bvABQ"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 478rpt6kc1z9sPT for ; Sat, 9 Nov 2019 07:05:10 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 87116C21E3B; Fri, 8 Nov 2019 20:01:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_MSPIKE_H2, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 950F1C21F48; Fri, 8 Nov 2019 19:55:22 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 7EFE2C21DE8; Fri, 8 Nov 2019 19:55:18 +0000 (UTC) Received: from mail-io1-f68.google.com (mail-io1-f68.google.com [209.85.166.68]) by lists.denx.de (Postfix) with ESMTPS id 501DBC21D65 for ; Fri, 8 Nov 2019 19:54:58 +0000 (UTC) Received: by mail-io1-f68.google.com with SMTP id j13so7685540ioe.0 for ; Fri, 08 Nov 2019 11:54:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=qOTeZ8ZcnuS0xd8yJZRV1efls6nteSeUBgnGA6nhI5Q=; b=lW+bvABQlX+u6unNAqdpU80wJw9AAHKEIHoPjhpkkzAf/tyglrXqFkQfBms41ZQsLS KVGFqJhwc3tF2DhhEp8Qor3pOWxXvXZzEpfZ7l+xJoPu6rUOmqIi7NIx0+JU3+oVzopy uciBwAhxh87pWwd4yOCpuus21AGIHoXD5uNcU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=qOTeZ8ZcnuS0xd8yJZRV1efls6nteSeUBgnGA6nhI5Q=; b=oe/SK1sggTu+SkRcs7qAYOn6bPkerupOxzhWO3wtyIfm8WcKKPBTrn8e5ousuXp0DL Sfi1YNN+zmeMtHt8HJ1b2sDPauVU00J6SPP1Wa7I8a/I6xLFP8hRXCtUUKXZQdJz+q/B TmipqXLjF4Ily0YJGBIb5p3nA+FrTfkbVui6aWERZ5fpZp9fdVV9iC6Dp/66daYKz0Uv eVUsEltEnlQZxplD5nmPmVs5i9TVTxYChZ6Ua7563DWsGzwq9LJ+20FeUst+Fr2qFwPZ JZQav0WRx7BFEzWT8Z/maVjNzPUik3daYU5SedOVPTtbGzalRkj9TwXjQv2C6215qlRp PMhw== X-Gm-Message-State: APjAAAWhUkNvnOoTvM23N6vgu//KeRUKaAMb809iADZHONRsqi+HJFBd i8quvOgpE+VyItRhDOopYvVaduXQeXvW7g== X-Google-Smtp-Source: APXvYqxfhwwc78K+nS3SK8stfWzl8+yT4/hXYgNRC2VeDnrfXY8dQ83YdqBAeRisTtzDRlVF4H5RkA== X-Received: by 2002:a6b:b355:: with SMTP id c82mr11667572iof.305.1573242897110; Fri, 08 Nov 2019 11:54:57 -0800 (PST) Received: from kiwi.bld.corp.google.com ([2620:15c:183:0:8223:87c:a681:66aa]) by smtp.gmail.com with ESMTPSA id l205sm622306ill.50.2019.11.08.11.54.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Nov 2019 11:54:56 -0800 (PST) From: Simon Glass To: U-Boot Mailing List Date: Fri, 8 Nov 2019 12:53:20 -0700 Message-Id: <20191108125120.v2.13.I6da24bfbaae4b2e00bb4f86b6ed687e364f02c3d@changeid> X-Mailer: git-send-email 2.24.0.rc1.363.gb1bccd3e3d-goog In-Reply-To: <20191108195348.110648-1-sjg@chromium.org> References: <20191108195348.110648-1-sjg@chromium.org> MIME-Version: 1.0 Cc: Tom Rini Subject: [U-Boot] [PATCH v2 13/41] common: Move env_get_ip() to net.h X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" This function relates to networking, so move it out of the common.h header file. Signed-off-by: Simon Glass Reviewed-by: Tom Rini --- 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 -static inline struct in_addr env_get_ip(char *var) -{ - return string_to_ip(env_get(var)); -} #include 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__ */