From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 3/5] console: Cleanup console activation
Date: Sun, 7 Oct 2012 13:39:49 +0200 [thread overview]
Message-ID: <1349609991-26567-4-git-send-email-s.hauer@pengutronix.de> (raw)
In-Reply-To: <1349609991-26567-1-git-send-email-s.hauer@pengutronix.de>
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>
---
common/console.c | 51 ++++++++++++++++++++++++++-------------------------
1 file 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;
}
--
1.7.10.4
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2012-10-07 11:40 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-07 11:39 [PATCH] misc improvements Sascha Hauer
2012-10-07 11:39 ` [PATCH 1/5] driver: print error message when probe fails Sascha Hauer
2012-10-07 11:39 ` [PATCH 2/5] resource: statically initialize iomem resource Sascha Hauer
2012-10-07 11:39 ` Sascha Hauer [this message]
2012-10-07 11:39 ` [PATCH 4/5] console: cleanup Kconfig Sascha Hauer
2012-10-07 11:39 ` [PATCH 5/5] startup: Print error message when initcall fails Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1349609991-26567-4-git-send-email-s.hauer@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox