summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-06-08 13:58:28 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2015-06-09 09:22:13 +0200
commite53e7218ad003c0fb48a02ce860c49e4220845d8 (patch)
tree2032d6eaaa3727659774344404e868d11c85355e
parent56b2fe72e856fe210ba1cdb5c154244a6d2d96ab (diff)
downloadbarebox-e53e7218ad003c0fb48a02ce860c49e4220845d8.tar.gz
barebox-e53e7218ad003c0fb48a02ce860c49e4220845d8.tar.xz
console: Add console_get_by_name
Commands like loadx/loady wish to find a console device by its name. Add a function for this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/console_common.c13
-rw-r--r--include/console.h1
2 files changed, 14 insertions, 0 deletions
diff --git a/common/console_common.c b/common/console_common.c
index 41a6929dba..1e362ab4e4 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -260,6 +260,19 @@ struct console_device *console_get_by_dev(struct device_d *dev)
}
EXPORT_SYMBOL(console_get_by_dev);
+struct console_device *console_get_by_name(const char *name)
+{
+ struct console_device *cdev;
+
+ for_each_console(cdev) {
+ if (!strcmp(cdev->devname, name))
+ return cdev;
+ }
+
+ return NULL;
+}
+EXPORT_SYMBOL(console_get_by_name);
+
/*
* @brief returns current used console device
*
diff --git a/include/console.h b/include/console.h
index 36dee9a3cc..839ec17e50 100644
--- a/include/console.h
+++ b/include/console.h
@@ -64,6 +64,7 @@ int console_register(struct console_device *cdev);
int console_unregister(struct console_device *cdev);
struct console_device *console_get_by_dev(struct device_d *dev);
+struct console_device *console_get_by_name(const char *name);
extern struct list_head console_list;
#define for_each_console(console) list_for_each_entry(console, &console_list, list)