summaryrefslogtreecommitdiffstats
path: root/common/console.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-11-11 12:54:18 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-17 12:03:47 +0100
commit749f337e60f39de68df38096d9d7c8687f2da434 (patch)
tree463b7c9d3173ea3c0f5846fe040b89b4db2ddb7b /common/console.c
parent67baa04396d2af50e3948c5ef836de6e6f6818ca (diff)
downloadbarebox-749f337e60f39de68df38096d9d7c8687f2da434.tar.gz
console: Set baudrate during registration
This makes sure that the cdev->baudrate field is always consistent with the hardware state. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common/console.c')
-rw-r--r--common/console.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/common/console.c b/common/console.c
index 84d4ea7..4a1d257 100644
--- a/common/console.c
+++ b/common/console.c
@@ -67,12 +67,6 @@ int console_set_active(struct console_device *cdev, unsigned flag)
if (!cdev->putc)
flag &= ~(CONSOLE_STDOUT | CONSOLE_STDERR);
- if (flag && !cdev->f_active) {
- /* The device is being activated, set its baudrate */
- if (cdev->setbrg)
- cdev->setbrg(cdev, cdev->baudrate);
- }
-
if (!flag && cdev->f_active && cdev->flush)
cdev->flush(cdev);
@@ -240,7 +234,7 @@ static int __console_puts(struct console_device *cdev, const char *s)
int console_register(struct console_device *newcdev)
{
struct device_d *dev = &newcdev->class_dev;
- int activate = 0;
+ int activate = 0, ret;
if (initialized == CONSOLE_UNINITIALIZED)
console_init_early();
@@ -258,6 +252,9 @@ int console_register(struct console_device *newcdev)
platform_device_register(dev);
if (newcdev->setbrg) {
+ ret = newcdev->setbrg(newcdev, CONFIG_BAUDRATE);
+ if (ret)
+ return ret;
newcdev->baudrate = CONFIG_BAUDRATE;
dev_add_param_int(dev, "baudrate", console_baudrate_set,
NULL, &newcdev->baudrate_param, "%u", newcdev);