summaryrefslogtreecommitdiffstats
path: root/common/console.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2012-10-06 22:57:02 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2012-10-09 08:57:10 +0200
commit2909d4ca4bba7e0faa8092b972dec95d8106af99 (patch)
tree522cf5248098bb1eee45142bf601ef59283a3b6e /common/console.c
parentbad4d7cd754579cfe20cba4c721b2c1269bfa2d8 (diff)
downloadbarebox-2909d4ca4bba7e0faa8092b972dec95d8106af99.tar.gz
console: Cleanup console activation
When CONFIG_CONSOLE_ACTIVATE_ALL is set, the banner will never be printed. Also, the console buffer is emptied when the first console is registered, even when it's not enabled. This patch cleans it up in a way that: - the console buffer is emptied once the first console is activated, not when it's registered. - Make sure that the banner is printed first, so that we can output things to the buffer before the banner is printed without ending up in having the banner in the middle of the other boot messages. - Use IS_ENABLED rather than ifdefs Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/console.c')
-rw-r--r--common/console.c51
1 files changed, 26 insertions, 25 deletions
diff --git a/common/console.c b/common/console.c
index 3dd964c..069e66e 100644
--- a/common/console.c
+++ b/common/console.c
@@ -44,6 +44,16 @@ EXPORT_SYMBOL(console_list);
static int initialized = 0;
+#define CONSOLE_BUFFER_SIZE 1024
+
+static char console_input_buffer[CONSOLE_BUFFER_SIZE];
+static char console_output_buffer[CONSOLE_BUFFER_SIZE];
+
+static struct kfifo __console_input_fifo;
+static struct kfifo __console_output_fifo;
+static struct kfifo *console_input_fifo = &__console_input_fifo;
+static struct kfifo *console_output_fifo = &__console_output_fifo;
+
static int console_std_set(struct device_d *dev, struct param_d *param,
const char *val)
{
@@ -74,6 +84,14 @@ static int console_std_set(struct device_d *dev, struct param_d *param,
dev_param_set_generic(dev, param, active);
+ if (initialized < CONSOLE_INIT_FULL) {
+ char ch;
+ initialized = CONSOLE_INIT_FULL;
+ barebox_banner();
+ while (kfifo_getc(console_output_fifo, &ch) == 0)
+ console_putc(CONSOLE_STDOUT, ch);
+ }
+
return 0;
}
@@ -108,16 +126,6 @@ static int console_baudrate_set(struct device_d *dev, struct param_d *param,
return 0;
}
-#define CONSOLE_BUFFER_SIZE 1024
-
-static char console_input_buffer[CONSOLE_BUFFER_SIZE];
-static char console_output_buffer[CONSOLE_BUFFER_SIZE];
-
-static struct kfifo __console_input_fifo;
-static struct kfifo __console_output_fifo;
-static struct kfifo *console_input_fifo = &__console_input_fifo;
-static struct kfifo *console_output_fifo = &__console_output_fifo;
-
static void console_init_early(void)
{
kfifo_init(console_input_fifo, console_input_buffer,
@@ -131,8 +139,7 @@ static void console_init_early(void)
int console_register(struct console_device *newcdev)
{
struct device_d *dev = &newcdev->class_dev;
- int first = 0;
- char ch;
+ int activate = 0;
if (initialized == CONSOLE_UNINITIALIZED)
console_init_early();
@@ -150,23 +157,17 @@ int console_register(struct console_device *newcdev)
dev_add_param(dev, "active", console_std_set, NULL, 0);
- initialized = CONSOLE_INIT_FULL;
-#ifdef CONFIG_CONSOLE_ACTIVATE_ALL
- dev_set_param(dev, "active", "ioe");
-#endif
-#ifdef CONFIG_CONSOLE_ACTIVATE_FIRST
- if (list_empty(&console_list)) {
- first = 1;
- dev_set_param(dev, "active", "ioe");
+ if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_FIRST)) {
+ if (list_empty(&console_list))
+ activate = 1;
+ } else if (IS_ENABLED(CONFIG_CONSOLE_ACTIVATE_ALL)) {
+ activate = 1;
}
-#endif
list_add_tail(&newcdev->list, &console_list);
- while (kfifo_getc(console_output_fifo, &ch) == 0)
- console_putc(CONSOLE_STDOUT, ch);
- if (first)
- barebox_banner();
+ if (activate)
+ dev_set_param(dev, "active", "ioe");
return 0;
}