summaryrefslogtreecommitdiffstats
path: root/common
diff options
context:
space:
mode:
authorRobert Jarzmik <robert.jarzmik@atosorigin.com>2011-11-24 04:01:26 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2011-12-05 17:59:02 +0100
commitea8314d19f6441061232549ec41ab0e21abd74ca (patch)
tree7187c9b51a458622aaa3500b890cf1509d895a70 /common
parent2504dcd33209db69ebb48ae7d1c5834cdc5c023f (diff)
downloadbarebox-ea8314d19f6441061232549ec41ab0e21abd74ca.tar.gz
barebox-ea8314d19f6441061232549ec41ab0e21abd74ca.tar.xz
console: add console unregistering
Some console are transient, like the USB connected serial console which should be removed when the USB connection is severed. Enable console removal for such devices. Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r--common/console.c24
-rw-r--r--common/console_simple.c4
2 files changed, 22 insertions, 6 deletions
diff --git a/common/console.c b/common/console.c
index 944dd07197..219148d097 100644
--- a/common/console.c
+++ b/common/console.c
@@ -154,13 +154,9 @@ int console_register(struct console_device *newcdev)
list_add_tail(&newcdev->list, &console_list);
- if (console_output_buffer) {
- while (kfifo_getc(console_output_buffer, &ch) == 0)
- console_putc(CONSOLE_STDOUT, ch);
- kfifo_free(console_output_buffer);
- console_output_buffer = NULL;
- }
+ while (kfifo_getc(console_output_buffer, &ch) == 0)
+ console_putc(CONSOLE_STDOUT, ch);
if (first)
barebox_banner();
@@ -168,6 +164,22 @@ int console_register(struct console_device *newcdev)
}
EXPORT_SYMBOL(console_register);
+int console_unregister(struct console_device *cdev)
+{
+ struct device_d *dev = &cdev->class_dev;
+ int status;
+
+ list_del(&cdev->list);
+ if (list_empty(&console_list))
+ initialized = CONSOLE_UNINITIALIZED;
+
+ status = unregister_device(dev);
+ if (!status)
+ memset(cdev, 0, sizeof(*cdev));
+ return status;
+}
+EXPORT_SYMBOL(console_unregister);
+
static int getc_raw(void)
{
struct console_device *cdev;
diff --git a/common/console_simple.c b/common/console_simple.c
index 7304d8ee05..7e0619db02 100644
--- a/common/console_simple.c
+++ b/common/console_simple.c
@@ -157,3 +157,7 @@ int console_register(struct console_device *newcdev)
}
return 0;
}
+
+int console_unregister(struct console_device *cdev)
+{
+}