Skip to content

Commit 84a3d1f

Browse files
pdgendtfabiobaltieri
authored andcommitted
drivers: serial: uart_native: Do not change API at runtime
The UART API is known at compile time based on Kconfig options. Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
1 parent 9dd07da commit 84a3d1f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/serial/uart_native_ptty.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,11 @@ static struct native_uart_status native_uart_status_0;
5454

5555
static struct uart_driver_api np_uart_driver_api_0 = {
5656
.poll_out = np_uart_poll_out,
57+
#if defined(CONFIG_NATIVE_UART_0_ON_OWN_PTY)
5758
.poll_in = np_uart_tty_poll_in,
59+
#else
60+
.poll_in = np_uart_stdin_poll_in,
61+
#endif
5862
};
5963

6064
#if defined(CONFIG_UART_NATIVE_POSIX_PORT_1_ENABLE)
@@ -89,11 +93,9 @@ static int np_uart_0_init(const struct device *dev)
8993

9094
d->in_fd = tty_fn;
9195
d->out_fd = tty_fn;
92-
np_uart_driver_api_0.poll_in = np_uart_tty_poll_in;
9396
} else { /* NATIVE_UART_0_ON_STDINOUT */
9497
d->in_fd = np_uart_ptty_get_stdin_fileno();
9598
d->out_fd = np_uart_ptty_get_stdout_fileno();
96-
np_uart_driver_api_0.poll_in = np_uart_stdin_poll_in;
9799
}
98100

99101
return 0;
@@ -160,8 +162,7 @@ static void np_uart_poll_out(const struct device *dev,
160162
* @retval 0 If a character arrived and was stored in p_char
161163
* @retval -1 If no character was available to read
162164
*/
163-
static int np_uart_stdin_poll_in(const struct device *dev,
164-
unsigned char *p_char)
165+
static int __maybe_unused np_uart_stdin_poll_in(const struct device *dev, unsigned char *p_char)
165166
{
166167
int in_f = ((struct native_uart_status *)dev->data)->in_fd;
167168
static bool disconnected;
@@ -189,8 +190,7 @@ static int np_uart_stdin_poll_in(const struct device *dev,
189190
* @retval 0 If a character arrived and was stored in p_char
190191
* @retval -1 If no character was available to read
191192
*/
192-
static int np_uart_tty_poll_in(const struct device *dev,
193-
unsigned char *p_char)
193+
static int __maybe_unused np_uart_tty_poll_in(const struct device *dev, unsigned char *p_char)
194194
{
195195
int n = -1;
196196
int in_f = ((struct native_uart_status *)dev->data)->in_fd;

0 commit comments

Comments
 (0)