From: Petr Hodina <[email protected]>

Gate the initr_net() INITCALL on CONFIG_NET_SKIP_BOOT_INIT at the
call site in initcall_run_r(), so boards with no wired NIC can skip
the boot-time probe and "Net:" banner without touching initr_net()
itself.

Signed-off-by: Petr Hodina <[email protected]>
---
initr_net() probes for Ethernet and prints a "Net:" banner when `NET` option
is enabled, which is not relevant for boards that use USB gadgets
for networking.

Add CONFIG_NET_SKIP_BOOT_INIT to skip that boot-time probe. Later
invocations still probe UCLASS_ETH normally. Defaults to n.
---
 common/board_r.c | 6 ++++--
 net/Kconfig      | 7 +++++++
 2 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/common/board_r.c b/common/board_r.c
index a397e20959d..1de4b4925b1 100644
--- a/common/board_r.c
+++ b/common/board_r.c
@@ -761,8 +761,10 @@ static void initcall_run_r(void)
        INITCALL(pci_ep_init);
 #endif
 #if CONFIG_IS_ENABLED(NET)
-       WATCHDOG_RESET();
-       INITCALL(initr_net);
+       if (!IS_ENABLED(CONFIG_NET_SKIP_BOOT_INIT)) {
+               WATCHDOG_RESET();
+               INITCALL(initr_net);
+       }
 #endif
 #if CONFIG_IS_ENABLED(POST)
        INITCALL(initr_post);
diff --git a/net/Kconfig b/net/Kconfig
index e712a0dd2ac..d42a68d8e12 100644
--- a/net/Kconfig
+++ b/net/Kconfig
@@ -14,6 +14,13 @@ menuconfig NET
 
 if NET
 
+config NET_SKIP_BOOT_INIT
+       bool "Skip the boot-time ethernet probe + 'Net:' banner"
+       help
+         By default init runs eth_initialize() if `NET` option is enabled.
+         Some boards do not have a wired NIC but use RNDIS or CDC-NCM
+         gadgets on the USB to provide network connectivity.
+
 choice
        prompt "Networking stack"
        default NET_LEGACY

---
base-commit: ece349ade2973e220f524ce59e59711cc919263f
change-id: 20260611-b4-net-skip-boot-init-86fcfcc0674d

Best regards,
--  
Petr Hodina <[email protected]>


Reply via email to