Compare commits

...

22 Commits

Author SHA1 Message Date
Simon Glass
eef0d75174 net: Move env_get_ip() out of the header file
This function requires access to env.h but it is a lot to include just
for the env_get() function. It eventually pulls in linux/byteorder which
causes a conflict with exfat which has its own byteorder functions.

Move the function to a C file instead.

Add includes to some other files to keep the build working.

Series-to: u-boot
Series-cc: trini
Series-cc: Jerome Forissier <jerome.forissier@linaro.org>
Series-version: 2
Cover-changes: 2
- Add patches for other files exposed by this change

Cover-letter:
Deal with exfat versus byteorder
Since exfat has its own byteorder functions we need to be careful about
including the normal U-Boot byteorder headers in code included by exfat.

One chain for include/linux/byteorder/little_endian.h is like this:

In file included from arch/sandbox/include/asm/byteorder.h:19,
                 from arch/sandbox/include/asm/byteorder.h:19,
                 from include/compiler.h:132,
                 from include/env.h:12,
                 from include/command.h:13,
                 from include/net-common.h:7,
                 from include/net.h:6,
                 from include/efi.h:23,
                 from include/blk.h:12,
                 from include/part.h:9,
                 from include/fs_internal.h:11,
                 from fs/exfat/io.c:52:

This series tidies things up so that efi.h can include net.h as
required.
END

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-04-30 19:02:05 -06:00
Simon Glass
1bf80a2df9 net: dc2114x: Include env.h to permit reading the environment
This file uses the environment but does not include the header file.
Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:05 -06:00
Simon Glass
c983d4bf75 net: Include env.h in pcap.c
This file uses the environment but does not include the header file.
Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:05 -06:00
Simon Glass
6b696a1308 net: Include string.h in net-legacy.h
This file uses memcpy() but does not include the header file. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:05 -06:00
Simon Glass
6967abb8d5 net: Include byteorder in net6.h
This file uses byteorder but does not include the header file. Update
it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:05 -06:00
Simon Glass
307522af23 elf: Only use network environment-variables if net enabled
If there is no network support it doesn't make sense to try to read
these variables. Add a condition to handle this.

This is needed so that env_get_ip() is not called when it is no-longer
a static inline, but included in net/ code.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:05 -06:00
Simon Glass
eff963c4e3 technexion: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:04 -06:00
Simon Glass
1c322798ad liebherr: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:04 -06:00
Simon Glass
ea837d13a3 google: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:04 -06:00
Simon Glass
9360b2920a freescale: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:04 -06:00
Simon Glass
0a092d7300 amlogic: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:04 -06:00
Simon Glass
b8a08e9684 synology: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:04 -06:00
Simon Glass
475fdf68e3 tegra: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:04 -06:00
Simon Glass
a7d82d54f5 advantech: Include env.h in imx8qm_dmsse20_a1
This file uses the environment but does not include the header file.
Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:02:04 -06:00
Simon Glass
d4e047735a toradex: Include env.h to permit reading the environment
Two files read from the environment but don't not include the correct
header. Update them.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 19:01:48 -06:00
Simon Glass
1a1ebb0347 ronetix: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 15:45:27 -06:00
Simon Glass
421e147102 phytec: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 15:45:09 -06:00
Simon Glass
06139bee86 venice: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 15:44:58 -06:00
Simon Glass
96477c1e74 imx8ulp_evk: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 15:44:37 -06:00
Simon Glass
06c9a116bf dhelectronics: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 15:44:03 -06:00
Simon Glass
635f9fb922 congatec: Include env.h to permit reading the environment
This file reads from the environment but does not include the correct
header. Update it.

Drop the unnecessary config.h while we are here.

Signed-off-by: Simon Glass <sjg@chromium.org>
2025-04-30 15:43:46 -06:00
Simon Glass
6dbb451889 net: Use a forward declaration for cmd_tbl in net-common.h
We don't need to include command.h just for this declaration. It
eventually pulls in linux/byteorder which causes a conflict with exfat
which has its own byteorder functions.

Use a forward declaration instead.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Jerome Forissier <jerome.forissier@linaro.org>
2025-04-30 08:37:27 -06:00
23 changed files with 55 additions and 29 deletions

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>

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>

View File

@@ -4,6 +4,7 @@
* Copyright 2019-2023 Kococonnector GmbH
*/
#include <env.h>
#include <errno.h>
#include <linux/libfdt.h>
#include <asm/io.h>

View File

@@ -5,6 +5,7 @@
*/
#include <dm.h>
#include <env.h>
#include <init.h>
#include <net.h>
#include <asm/io.h>

View File

@@ -3,7 +3,8 @@
* Copyright 2018 congatec AG
* 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>

View File

@@ -5,6 +5,7 @@
*/
#include <dm.h>
#include <env.h>
#include <i2c_eeprom.h>
#include <net.h>

View File

@@ -3,6 +3,7 @@
* Copyright 2020 NXP
*/
#include <env.h>
#include <miiphy.h>
#include <netdev.h>
#include <asm/arch/imx8ulp-pins.h>

View File

@@ -3,6 +3,7 @@
* Copyright (C) 2015 Freescale Semiconductor, Inc.
*/
#include <env.h>
#include <init.h>
#include <net.h>
#include <asm/arch/clock.h>

View File

@@ -3,6 +3,7 @@
* Copyright 2021 Gateworks Corporation
*/
#include <env.h>
#include <fdt_support.h>
#include <init.h>
#include <led.h>

View File

@@ -2,6 +2,8 @@
/*
* Copyright 2022 Google LLC
*/
#include <env.h>
#include <net.h>
#include <errno.h>
#include "mercury_aa1.h"

View File

@@ -13,6 +13,7 @@
*
*/
#include <env.h>
#include <fdt_support.h>
#include <init.h>
#include <log.h>

View File

@@ -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>

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>

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>

View File

@@ -4,6 +4,7 @@
*/
#include <cpu_func.h>
#include <env.h>
#include <init.h>
#include <net.h>
#include <asm/arch/clock.h>

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>

View File

@@ -242,31 +242,34 @@ int do_bootvx(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
* The following parameters are only needed if 'bootdev'
* is an ethernet device, otherwise they are optional.
*/
tmp = env_get("ipaddr");
if (tmp) {
ptr += sprintf(build_buf + ptr, "e=%s", tmp);
tmp = env_get("netmask");
if (IS_ENABLED(CONFIG_NET) || IS_ENABLED(CONFIG_NET_LWIP)) {
tmp = env_get("ipaddr");
if (tmp) {
u32 mask = env_get_ip("netmask").s_addr;
ptr += sprintf(build_buf + ptr,
":%08x ", ntohl(mask));
} else {
ptr += sprintf(build_buf + ptr, " ");
ptr += sprintf(build_buf + ptr, "e=%s", tmp);
tmp = env_get("netmask");
if (tmp) {
u32 mask = env_get_ip("netmask").s_addr;
ptr += sprintf(build_buf + ptr,
":%08x ", ntohl(mask));
} else {
ptr += sprintf(build_buf + ptr, " ");
}
}
tmp = env_get("serverip");
if (tmp)
ptr += sprintf(build_buf + ptr, "h=%s ", tmp);
tmp = env_get("gatewayip");
if (tmp)
ptr += sprintf(build_buf + ptr, "g=%s ", tmp);
tmp = env_get("hostname");
if (tmp)
ptr += sprintf(build_buf + ptr, "tn=%s ", tmp);
}
tmp = env_get("serverip");
if (tmp)
ptr += sprintf(build_buf + ptr, "h=%s ", tmp);
tmp = env_get("gatewayip");
if (tmp)
ptr += sprintf(build_buf + ptr, "g=%s ", tmp);
tmp = env_get("hostname");
if (tmp)
ptr += sprintf(build_buf + ptr, "tn=%s ", tmp);
tmp = env_get("othbootargs");
if (tmp) {
strcpy(build_buf + ptr, tmp);

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>

View File

@@ -4,8 +4,6 @@
#define __NET_COMMON_H__
#include <asm/cache.h>
#include <command.h>
#include <env.h>
#include <hexdump.h>
#include <linux/if_ether.h>
#include <linux/sizes.h>
@@ -13,6 +11,8 @@
#include <rand.h>
#include <time.h>
struct cmd_tbl;
#define DEBUG_NET_PKT_TRACE 0 /* Trace all packet data */
/*
@@ -463,10 +463,7 @@ int update_tftp(ulong addr, char *interface, char *devstring);
* 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));
}
struct in_addr env_get_ip(char *var);
int net_init(void);

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;

View File

@@ -11,6 +11,7 @@
#define __NET6_H__
#include <net.h>
#include <asm/byteorder.h>
#include <linux/ctype.h>
#include <linux/errno.h>

View File

@@ -1,4 +1,5 @@
// SPDX-License-Identifier: GPL-2.0
#include <env.h>
#include <net-common.h>
void copy_filename(char *dst, const char *src, int size)
@@ -25,3 +26,8 @@ int wget_request(ulong dst_addr, char *uri, struct wget_http_info *info)
wget_info = info ? info : &default_wget_info;
return wget_with_dns(dst_addr, uri);
}
struct in_addr env_get_ip(char *var)
{
return string_to_ip(env_get(var));
}

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>