summaryrefslogtreecommitdiff
path: root/common/stdio.c
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2021-02-11 17:09:36 +0200
committerTom Rini <trini@konsulko.com>2021-02-16 11:16:07 -0500
commitd9b0ac90baf499d215462ed7afffbfd22a58340b (patch)
treeaf6936c29035a93b11be0499cf18fe0d3dde1a2e /common/stdio.c
parent99cb2b996bd649d98069a95941beaaade0a4447a (diff)
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 <andriy.shevchenko@linux.intel.com>
Diffstat (limited to 'common/stdio.c')
-rw-r--r--common/stdio.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/common/stdio.c b/common/stdio.c
index 61fc087368..d4acc5256c 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)
{