From d9b0ac90baf499d215462ed7afffbfd22a58340b Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Thu, 11 Feb 2021 17:09:36 +0200 Subject: stdio: Introduce a new helper stdio_file_to_flags() Let's deduplicate existing copies by splitting off to a new helper. Signed-off-by: Andy Shevchenko --- common/stdio.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'common/stdio.c') diff --git a/common/stdio.c b/common/stdio.c index 61fc0873684..d4acc5256c1 100644 --- a/common/stdio.c +++ b/common/stdio.c @@ -28,6 +28,19 @@ static struct stdio_dev devs; struct stdio_dev *stdio_devices[] = { NULL, NULL, NULL }; char *stdio_names[MAX_FILES] = { "stdin", "stdout", "stderr" }; +int stdio_file_to_flags(const int file) +{ + switch (file) { + case stdin: + return DEV_FLAGS_INPUT; + case stdout: + case stderr: + return DEV_FLAGS_OUTPUT; + default: + return -EINVAL; + } +} + #if CONFIG_IS_ENABLED(SYS_DEVICE_NULLDEV) static void nulldev_putc(struct stdio_dev *dev, const char c) { -- cgit v1.2.3