[PATCH 03/12] console: Add console_get_by_name

Sascha Hauer s.hauer at pengutronix.de
Mon Jun 8 23:21:06 PDT 2015


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 at pengutronix.de>
---
 common/console_common.c | 13 +++++++++++++
 include/console.h       |  1 +
 2 files changed, 14 insertions(+)

diff --git a/common/console_common.c b/common/console_common.c
index 41a6929..1e362ab 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 945bdcb..c2622c9 100644
--- a/include/console.h
+++ b/include/console.h
@@ -63,6 +63,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)
-- 
2.1.4




More information about the barebox mailing list