From 59f067171fe4e1cab6ccff0b35c140d13a88f9cf Mon Sep 17 00:00:00 2001 From: Benjamin Valentin Date: Mon, 2 Jan 2023 18:11:24 +0100 Subject: [PATCH] core/init: call vfs_bind_stdio() in early_init() --- core/lib/init.c | 8 ++++++++ cpu/native/stdio_native/stdio_native.c | 4 ---- drivers/ethos/stdio.c | 7 ------- pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c | 8 -------- sys/net/application_layer/telnet/stdio_telnet.c | 7 ------- sys/stdio_nimble/stdio_nimble.c | 8 -------- sys/stdio_null/stdio_null.c | 7 ------- sys/stdio_rtt/stdio_rtt.c | 8 -------- sys/stdio_semihosting/stdio_semihosting.c | 7 ------- sys/stdio_uart/stdio_uart.c | 8 -------- sys/usb/usbus/cdc/acm/cdc_acm_stdio.c | 8 -------- 11 files changed, 8 insertions(+), 72 deletions(-) diff --git a/core/lib/init.c b/core/lib/init.c index cee564e0e5..b20252945d 100644 --- a/core/lib/init.c +++ b/core/lib/init.c @@ -31,6 +31,10 @@ #include "thread.h" #include "stdio_base.h" +#if IS_USED(MODULE_VFS) +#include "vfs.h" +#endif + #define ENABLE_DEBUG 0 #include "debug.h" @@ -113,4 +117,8 @@ void early_init(void) } stdio_init(); + +#if MODULE_VFS + vfs_bind_stdio(); +#endif } diff --git a/cpu/native/stdio_native/stdio_native.c b/cpu/native/stdio_native/stdio_native.c index fe2ffef233..e79bec4eba 100644 --- a/cpu/native/stdio_native/stdio_native.c +++ b/cpu/native/stdio_native/stdio_native.c @@ -15,15 +15,11 @@ #include "kernel_defines.h" #include "native_internal.h" -#include "vfs.h" #include "stdio_base.h" void stdio_init(void) { - if (IS_USED(MODULE_VFS)) { - vfs_bind_stdio(); - } } ssize_t stdio_read(void* buffer, size_t max_len) diff --git a/drivers/ethos/stdio.c b/drivers/ethos/stdio.c index aff424a9ae..f7302329c7 100644 --- a/drivers/ethos/stdio.c +++ b/drivers/ethos/stdio.c @@ -24,9 +24,6 @@ #include "ethos.h" #include "isrpipe.h" #include "stdio_uart.h" -#if IS_USED(MODULE_VFS) -#include "vfs.h" -#endif extern ethos_t ethos; @@ -41,10 +38,6 @@ static void _isrpipe_write(void *arg, uint8_t data) void stdio_init(void) { uart_init(ETHOS_UART, ETHOS_BAUDRATE, _isrpipe_write, ðos_stdio_isrpipe); - -#if MODULE_VFS - vfs_bind_stdio(); -#endif } extern unsigned ethos_unstuff_readbyte(uint8_t *buf, uint8_t byte, diff --git a/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c b/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c index eb95702ef8..16e3ae6c6a 100644 --- a/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c +++ b/pkg/tinyusb/cdc_acm_stdio/cdc_acm_stdio.c @@ -28,18 +28,10 @@ #include "tusb.h" #include "tinyusb.h" -#if MODULE_VFS -#include "vfs.h" -#endif - static mutex_t data_lock = MUTEX_INIT_LOCKED; void stdio_init(void) { - /* Initialize this side of the CDC ACM pipe */ -#if MODULE_VFS - vfs_bind_stdio(); -#endif } #if IS_USED(MODULE_STDIO_AVAILABLE) diff --git a/sys/net/application_layer/telnet/stdio_telnet.c b/sys/net/application_layer/telnet/stdio_telnet.c index 99e96b5ac9..3cd64ef078 100644 --- a/sys/net/application_layer/telnet/stdio_telnet.c +++ b/sys/net/application_layer/telnet/stdio_telnet.c @@ -29,9 +29,6 @@ #include "stdio_uart.h" #include "periph/uart.h" #endif -#if IS_USED(MODULE_VFS) -#include "vfs.h" -#endif #ifdef CPU_NATIVE #include "native_internal.h" #endif @@ -62,10 +59,6 @@ static inline int _write_fallback(const void* buffer, size_t len) void stdio_init(void) { _init_fallback(); - -#if IS_USED(MODULE_VFS) - vfs_bind_stdio(); -#endif } ssize_t stdio_read(void* buffer, size_t count) diff --git a/sys/stdio_nimble/stdio_nimble.c b/sys/stdio_nimble/stdio_nimble.c index 1edf9837f6..fe93c65d8b 100644 --- a/sys/stdio_nimble/stdio_nimble.c +++ b/sys/stdio_nimble/stdio_nimble.c @@ -39,10 +39,6 @@ #include "periph/uart.h" #endif /* IS_USED(MODULE_STDIO_NIMBLE_DEBUG) */ -#if IS_USED(MODULE_VFS) -#include "vfs.h" -#endif - #include "tsrb.h" #include "isrpipe.h" #include "stdio_nimble.h" @@ -312,10 +308,6 @@ static int gatt_svr_chr_access_stdin( void stdio_init(void) { -#if IS_USED(MODULE_VFS) - vfs_bind_stdio(); -#endif - #if IS_USED(MODULE_STDIO_NIMBLE_DEBUG) uart_init(STDIO_UART_DEV, STDIO_UART_BAUDRATE, NULL, NULL); #endif diff --git a/sys/stdio_null/stdio_null.c b/sys/stdio_null/stdio_null.c index 2f55deac4c..95f238c174 100644 --- a/sys/stdio_null/stdio_null.c +++ b/sys/stdio_null/stdio_null.c @@ -22,18 +22,11 @@ #include "stdio_base.h" -#if MODULE_VFS -#include "vfs.h" -#endif - #define ENABLE_DEBUG 0 #include "debug.h" void stdio_init(void) { -#if MODULE_VFS - vfs_bind_stdio(); -#endif } ssize_t stdio_read(void* buffer, size_t count) diff --git a/sys/stdio_rtt/stdio_rtt.c b/sys/stdio_rtt/stdio_rtt.c index d17ee05c55..7996719049 100644 --- a/sys/stdio_rtt/stdio_rtt.c +++ b/sys/stdio_rtt/stdio_rtt.c @@ -82,10 +82,6 @@ #include "thread.h" #include "ztimer.h" -#if MODULE_VFS -#include "vfs.h" -#endif - /* This parameter affects the bandwidth of both input and output. Decreasing it will significantly improve bandwidth at the cost of CPU time. */ #ifndef STDIO_POLL_INTERVAL_MS @@ -282,10 +278,6 @@ void stdio_init(void) { blocking_stdout = 1; #endif -#if MODULE_VFS - vfs_bind_stdio(); -#endif - /* the mutex should start locked */ mutex_lock(&_rx_mutex); } diff --git a/sys/stdio_semihosting/stdio_semihosting.c b/sys/stdio_semihosting/stdio_semihosting.c index dd0d0cebb1..31cad36f9e 100644 --- a/sys/stdio_semihosting/stdio_semihosting.c +++ b/sys/stdio_semihosting/stdio_semihosting.c @@ -27,10 +27,6 @@ #include "stdio_semihosting.h" #include "ztimer.h" -#if MODULE_VFS -#include "vfs.h" -#endif - /** * @brief Rate at which the stdin read polls (breaks) the debugger for input * data in milliseconds @@ -149,9 +145,6 @@ static ssize_t _semihosting_read(uint8_t *buffer, size_t len) void stdio_init(void) { -#if MODULE_VFS - vfs_bind_stdio(); -#endif } ssize_t stdio_read(void* buffer, size_t count) diff --git a/sys/stdio_uart/stdio_uart.c b/sys/stdio_uart/stdio_uart.c index 19e0530f8b..5568d3e815 100644 --- a/sys/stdio_uart/stdio_uart.c +++ b/sys/stdio_uart/stdio_uart.c @@ -36,10 +36,6 @@ #include "periph/uart.h" #include "stdio_uart.h" -#if MODULE_VFS -#include "vfs.h" -#endif - #define ENABLE_DEBUG 0 #include "debug.h" @@ -62,10 +58,6 @@ void stdio_init(void) } uart_init(STDIO_UART_DEV, STDIO_UART_BAUDRATE, cb, arg); - -#if MODULE_VFS - vfs_bind_stdio(); -#endif } #if IS_USED(MODULE_STDIO_AVAILABLE) diff --git a/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c b/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c index 5a106ad685..d340970c3c 100644 --- a/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c +++ b/sys/usb/usbus/cdc/acm/cdc_acm_stdio.c @@ -30,10 +30,6 @@ #include "usb/usbus.h" #include "usb/usbus/cdc/acm.h" -#if MODULE_VFS -#include "vfs.h" -#endif - static usbus_cdcacm_device_t cdcacm; static uint8_t _cdc_tx_buf_mem[CONFIG_USBUS_CDC_ACM_STDIO_BUF_SIZE]; static uint8_t _cdc_rx_buf_mem[CONFIG_USBUS_CDC_ACM_STDIO_BUF_SIZE]; @@ -41,10 +37,6 @@ static isrpipe_t _cdc_stdio_isrpipe = ISRPIPE_INIT(_cdc_rx_buf_mem); void stdio_init(void) { - /* Initialize this side of the CDC ACM pipe */ -#if MODULE_VFS - vfs_bind_stdio(); -#endif } #if IS_USED(MODULE_STDIO_AVAILABLE)