summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2013-10-03 09:21:53 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-10-06 13:19:46 +0200
commit6a5121f74894ed2d3514b59bd287d126eb7f1488 (patch)
tree8259be40e6cad36b274aeb3fb9768c71a6c8714a /common
parent651a23a69e598658e05e9e55d390db3a3f2a738a (diff)
downloadbarebox-6a5121f74894ed2d3514b59bd287d126eb7f1488.tar.gz
barebox-6a5121f74894ed2d3514b59bd287d126eb7f1488.tar.xz
console: factorise function to get the first enabled console
rename it to console_get_first_active Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/console_common.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/common/console_common.c b/common/console_common.c
index d139d1a8fe..a3aca6f46b 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -108,3 +108,25 @@ int fputc(int fd, char c)
return 0;
}
EXPORT_SYMBOL(fputc);
+
+/*
+ * @brief returns current used console device
+ *
+ * @return console device which is registered with CONSOLE_STDIN and
+ * CONSOLE_STDOUT
+ */
+struct console_device *console_get_first_active(void)
+{
+ struct console_device *cdev;
+ /*
+ * Assumption to have BOTH CONSOLE_STDIN AND STDOUT in the
+ * same output console
+ */
+ for_each_console(cdev) {
+ if ((cdev->f_active & (CONSOLE_STDIN | CONSOLE_STDOUT)))
+ return cdev;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL(console_get_first_active);