Merge patch series "Remove <env.h> from <net.h>"

Tom Rini <trini@konsulko.com> says:

Hey all,

This is a v3 of Simon's series[1] and depends on the series[2] I posted
the other day that removes <env.h> from <command.h>. With this series
done, I believe we've tackled all of the current cases of headers which
include <env.h> without directly needing it. Much of this series is in
fact Simon's v2 with the main differneces being:
- Removing <env.h> from <net.h> at the end
- Removing env_to_ip() given how little it's used rather than shuffling
  around where it's declared and un-inline'ing it. For a rarely used
  helper, this ends up being cleaner I think. Especially looking at some
  of the users (which called env_get repeatedly). If there's strong
  opinion here about using the other method[3] we can do that instead.
- Setting aside for now how to handle CMD_ELF=y and NO_NET=y because
  today it's actually fine as we unconditionally build lib/net_utils.c
  where string_to_ip() is defined. I'm unsure if a further series is
  warranted here or not. We rely on link-time optimization to keep code
  readable too.

[1]: https://lore.kernel.org/all/20250501010456.3930701-1-sjg@chromium.org
[2]: https://lore.kernel.org/all/20250514225002.15361-1-trini@konsulko.com
[3]: https://lore.kernel.org/all/20250501010456.3930701-23-sjg@chromium.org
Link: https://lore.kernel.org/r/20250515234154.1859366-1-trini@konsulko.com
This commit is contained in:
Tom Rini
2025-05-29 08:31:07 -06:00
47 changed files with 52 additions and 23 deletions
+1
View File
@@ -3,6 +3,7 @@
* Copyright (c) 2010-2016, NVIDIA CORPORATION.
*/
#include <env.h>
#include <fdtdec.h>
#include <stdlib.h>
#include <asm/arch-tegra/cboot.h>
+1
View File
@@ -7,6 +7,7 @@
*
*/
#include <cpu_func.h>
#include <env.h>
#include <hang.h>
#include <init.h>
#include <spl.h>
+1
View File
@@ -4,6 +4,7 @@
* Copyright (C) 2015 Phil Sutter <phil@nwl.cc>
*/
#include <env.h>
#include <init.h>
#include <miiphy.h>
#include <asm/global_data.h>
@@ -7,6 +7,7 @@
#include <dwc3-uboot.h>
#include <efi.h>
#include <efi_loader.h>
#include <env.h>
#include <errno.h>
#include <miiphy.h>
#include <netdev.h>
@@ -4,6 +4,7 @@
* Copyright 2019-2023 Kococonnector GmbH
*/
#include <env.h>
#include <errno.h>
#include <linux/libfdt.h>
#include <asm/io.h>
+1
View File
@@ -5,6 +5,7 @@
*/
#include <dm.h>
#include <env.h>
#include <init.h>
#include <net.h>
#include <asm/io.h>
+1
View File
@@ -6,6 +6,7 @@
#include <config.h>
#include <cpu_func.h>
#include <env.h>
#include <flash.h>
#include <image.h>
#include <init.h>
+1
View File
@@ -4,6 +4,7 @@
* Copyright (C) 2019 Oliver Graute <oliver.graute@kococonnector.com>
*/
#include <config.h>
#include <env.h>
#include <errno.h>
#include <linux/libfdt.h>
#include <fsl_esdhc.h>
+1
View File
@@ -12,6 +12,7 @@
#include <asm/mach-imx/boot_mode.h>
#include <asm/mach-imx/iomux-v3.h>
#include <dm/uclass.h>
#include <env.h>
#include <hang.h>
#include <i2c_eeprom.h>
#include <image.h>
+1
View File
@@ -5,6 +5,7 @@
*/
#include <dm.h>
#include <env.h>
#include <i2c_eeprom.h>
#include <net.h>
#include <u-boot/crc.h>
@@ -3,6 +3,7 @@
* Copyright 2020 NXP
*/
#include <env.h>
#include <miiphy.h>
#include <netdev.h>
#include <asm/arch/imx8ulp-pins.h>
@@ -3,6 +3,7 @@
* Copyright (C) 2015 Freescale Semiconductor, Inc.
*/
#include <env.h>
#include <init.h>
#include <net.h>
#include <asm/arch/clock.h>
+1
View File
@@ -6,6 +6,7 @@
*/
#include <command.h>
#include <env.h>
#include <fdt_support.h>
#include <gsc.h>
#include <hwconfig.h>
+1
View File
@@ -3,6 +3,7 @@
* Copyright 2021 Gateworks Corporation
*/
#include <env.h>
#include <fdt_support.h>
#include <init.h>
#include <led.h>
+1
View File
@@ -17,6 +17,7 @@
#include <asm/io.h>
#include <asm/mach-imx/video.h>
#include <command.h>
#include <env.h>
#include <i2c.h>
#include <input.h>
#include <ipu_pixfmt.h>
+2
View File
@@ -2,6 +2,8 @@
/*
* Copyright 2022 Google LLC
*/
#include <env.h>
#include <net.h>
#include <errno.h>
#include "mercury_aa1.h"
+1
View File
@@ -6,6 +6,7 @@
* Copyright 2013 Freescale Semiconductor, Inc.
*/
#include <env.h>
#include <event.h>
#include <asm/cache.h>
#include <asm/fsl_fdt.h>
+1
View File
@@ -13,6 +13,7 @@
*
*/
#include <env.h>
#include <fdt_support.h>
#include <init.h>
#include <log.h>
@@ -4,6 +4,7 @@
* Author: Daniel Schultz <d.schultz@phytec.de>
*/
#include <env.h>
#include <malloc.h>
#include <u-boot/crc.h>
#include <net.h>
+1
View File
@@ -6,6 +6,7 @@
#include <malloc.h>
#include <errno.h>
#include <env.h>
#include <asm/io.h>
#include <miiphy.h>
#include <asm/mach-imx/iomux-v3.h>
+1
View File
@@ -3,6 +3,7 @@
* Copyright 2018 NXP
*/
#include <env.h>
#include <miiphy.h>
#include <asm-generic/gpio.h>
#include <asm/arch/imx8mq_pins.h>
+1
View File
@@ -11,6 +11,7 @@
#include <config.h>
#include <bootstage.h>
#include <dm.h>
#include <env.h>
#include <fdt_support.h>
#include <i2c.h>
#include <led.h>
+1
View File
@@ -3,6 +3,7 @@
* Copyright (C) 2017 NXP Semiconductors
*/
#include <env.h>
#include <init.h>
#include <net.h>
#include <asm/arch/clock.h>
+1
View File
@@ -8,6 +8,7 @@
*/
#include <efi_loader.h>
#include <env.h>
#include <generic-phy.h>
#include <image.h>
#include <net.h>
@@ -4,6 +4,7 @@
*/
#include <cpu_func.h>
#include <env.h>
#include <init.h>
#include <net.h>
#include <asm/arch/clock.h>
+1 -1
View File
@@ -3,7 +3,7 @@
* Copyright 2020-2021 Toradex
*/
#include <config.h>
#include <env.h>
#include <init.h>
#include <asm/arch/clock.h>
#include <asm/arch/sys_proto.h>
+1
View File
@@ -15,6 +15,7 @@
#include <dm.h>
#include <efi.h>
#include <efi_loader.h>
#include <env.h>
#include <fs.h>
#include <malloc.h>
#include <mapmem.h>
+1
View File
@@ -13,6 +13,7 @@
#include <bootmeth.h>
#include <command.h>
#include <dm.h>
#include <env.h>
#include <extlinux.h>
#include <fs.h>
#include <log.h>
+1 -1
View File
@@ -247,7 +247,7 @@ int do_bootvx(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
ptr += sprintf(build_buf + ptr, "e=%s", tmp);
tmp = env_get("netmask");
if (tmp) {
u32 mask = env_get_ip("netmask").s_addr;
u32 mask = string_to_ip(tmp).s_addr;
ptr += sprintf(build_buf + ptr,
":%08x ", ntohl(mask));
} else {
+1 -1
View File
@@ -564,7 +564,7 @@ int do_sntp(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
char *toff;
if (argc < 2) {
net_ntp_server = env_get_ip("ntpserverip");
net_ntp_server = string_to_ip(env_get("ntpserverip"));
if (net_ntp_server.s_addr == 0) {
printf("ntpserverip not set\n");
return CMD_RET_FAILURE;
+1
View File
@@ -5,6 +5,7 @@
*/
#include <command.h>
#include <env.h>
#include <fs.h>
#include <net.h>
#include <net6.h>
+1
View File
@@ -3,6 +3,7 @@
#include <asm/io.h>
#include <cpu_func.h>
#include <dm.h>
#include <env.h>
#include <malloc.h>
#include <net.h>
#include <netdev.h>
+6 -5
View File
@@ -61,8 +61,8 @@ static int is_broadcast(struct in_addr ip)
/* update only when the environment has changed */
if (env_changed_id != env_id) {
netmask = env_get_ip("netmask");
our_ip = env_get_ip("ipaddr");
netmask = string_to_ip(env_get("netmask"));
our_ip = string_to_ip(env_get("ipaddr"));
env_changed_id = env_id;
}
@@ -81,11 +81,12 @@ static int refresh_settings_from_env(void)
/* update only when the environment has changed */
if (env_changed_id != env_id) {
if (env_get("ncip")) {
nc_ip = env_get_ip("ncip");
char *tmp = env_get("ncip");
if (tmp) {
nc_ip = string_to_ip(tmp);
if (!nc_ip.s_addr)
return -1; /* ncip is 0.0.0.0 */
p = strchr(env_get("ncip"), ':');
p = strchr(tmp, ':');
if (p != NULL) {
nc_out_port = dectoul(p + 1, NULL);
nc_in_port = nc_out_port;
+1
View File
@@ -12,6 +12,7 @@
#include <dm.h>
#include <dm/device-internal.h>
#include <env.h>
#include <image.h>
#include <log.h>
#include <malloc.h>
-14
View File
@@ -5,7 +5,6 @@
#include <asm/cache.h>
#include <command.h>
#include <env.h>
#include <hexdump.h>
#include <linux/if_ether.h>
#include <linux/sizes.h>
@@ -456,19 +455,6 @@ void net_process_received_packet(uchar *in_packet, int len);
*/
int update_tftp(ulong addr, char *interface, char *devstring);
/**
* env_get_ip() - Convert an environment value to an ip address
*
* @var: Environment variable to convert. The value of this variable must be
* in the 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));
}
int net_init(void);
/* Called when a network operation fails to know if it should be re-tried */
+1
View File
@@ -17,6 +17,7 @@
#include <log.h>
#include <time.h>
#include <linux/if_ether.h>
#include <linux/string.h>
struct bd_info;
struct cmd_tbl;
+1
View File
@@ -11,6 +11,7 @@
#define __NET6_H__
#include <net.h>
#include <asm/byteorder.h>
#include <linux/ctype.h>
#include <linux/errno.h>
+1
View File
@@ -13,6 +13,7 @@
#include <dm.h>
#include <efi.h>
#include <efi_device_path.h>
#include <env.h>
#include <log.h>
#include <malloc.h>
#include <net.h>
+1
View File
@@ -19,6 +19,7 @@
#include <efi_device_path.h>
#include <efi_loader.h>
#include <env.h>
#include <dm.h>
#include <linux/sizes.h>
#include <malloc.h>
+1 -1
View File
@@ -106,7 +106,7 @@ static void configure_wait(void)
void link_local_start(void)
{
ip = env_get_ip("llipaddr");
ip = string_to_ip(env_get("llipaddr"));
if (ip.s_addr != 0 &&
(ntohl(ip.s_addr) & IN_CLASSB_NET) != LINKLOCAL_ADDR) {
puts("invalid link address");
+1
View File
@@ -3,6 +3,7 @@
#include <command.h>
#include <console.h>
#include <env.h>
#include <log.h>
#include <dm/device.h>
#include <linux/delay.h>
+1
View File
@@ -3,6 +3,7 @@
#include <command.h>
#include <console.h>
#include <env.h>
#include <lwip/dns.h>
#include <lwip/timeouts.h>
#include <net.h>
+1
View File
@@ -3,6 +3,7 @@
/* Copyright (C) 2024 Linaro Ltd. */
#include <command.h>
#include <env.h>
#include <dm/device.h>
#include <dm/uclass.h>
#include <hexdump.h>
+1
View File
@@ -6,6 +6,7 @@
#include <display_options.h>
#include <dm/device.h>
#include <efi_loader.h>
#include <env.h>
#include <image.h>
#include <linux/delay.h>
#include <linux/kconfig.h>
+1
View File
@@ -5,6 +5,7 @@
#include <console.h>
#include <display_options.h>
#include <efi_loader.h>
#include <env.h>
#include <image.h>
#include <linux/kconfig.h>
#include <lwip/apps/http_client.h>
+1
View File
@@ -3,6 +3,7 @@
* Copyright 2019 Ramon Fried <rfried.dev@gmail.com>
*/
#include <env.h>
#include <net.h>
#include <net/pcap.h>
#include <time.h>
+1
View File
@@ -3,6 +3,7 @@
* Copyright 2020-2021 NXP
*/
#include <env.h>
#include <net/dsa.h>
#include <dm/test.h>
#include <test/ut.h>