aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/stdio.c13
-rw-r--r--include/stdio_dev.h2
2 files changed, 15 insertions, 0 deletions
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)
{
diff --git a/include/stdio_dev.h b/include/stdio_dev.h
index 109a68d0640..8fb9a12dd87 100644
--- a/include/stdio_dev.h
+++ b/include/stdio_dev.h
@@ -18,6 +18,8 @@
#define DEV_FLAGS_OUTPUT 0x00000002 /* Device can be used as output console */
#define DEV_FLAGS_DM 0x00000004 /* Device priv is a struct udevice * */
+int stdio_file_to_flags(const int file);
+
/* Device information */
struct stdio_dev {
int flags; /* Device flags: input/output/system */