This makes sure that the cdev->baudrate field is always consistent with
the hardware state.

Signed-off-by: Sascha Hauer <[email protected]>
---
 common/console.c | 11 ++++-------
 1 file 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);
-- 
2.6.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

Reply via email to