diff options
author | Antony Pavlov <antonynpavlov@gmail.com> | 2021-08-17 13:10:59 +0300 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2021-10-04 14:02:28 +0200 |
commit | 2ac357afe9343948d46068bdefc350c9d7a5ec8b (patch) | |
tree | 3204a3fb284285ed61d9a309ab2a932618c93529 /common | |
parent | b239e5920ed19e3d8cd0d1a8d3cf069beefa0bbd (diff) | |
download | barebox-2ac357afe9343948d46068bdefc350c9d7a5ec8b.tar.gz barebox-2ac357afe9343948d46068bdefc350c9d7a5ec8b.tar.xz |
console: support set baudrate for fixed baudrate drivers
There are console drivers (linux, virtio, litex)
that don't support baud rate setting and has
no setbrg (set baudrate) callback, so
console_set_baudrate() returns -ENOSYS.
At the other hand console_set_baudrate() SUCCESS
return value is needed for the loadx/loady commands
correct work.
See discussion here:
http://lists.infradead.org/pipermail/barebox/2021-May/036237.html
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Reviewed-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Tested-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Link: https://lore.barebox.org/20210817101104.114945-4-antonynpavlov@gmail.com
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'common')
-rw-r--r-- | common/console.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/common/console.c b/common/console.c index ad1a6aaab2..c902239e31 100644 --- a/common/console.c +++ b/common/console.c @@ -165,12 +165,12 @@ int console_set_baudrate(struct console_device *cdev, unsigned baudrate) int ret; unsigned char c; - if (!cdev->setbrg) - return -ENOSYS; - if (cdev->baudrate == baudrate) return 0; + if (!cdev->setbrg) + return -ENOSYS; + /* * If the device is already active, change its baudrate. * The baudrate of an inactive device will be set at activation time. @@ -336,11 +336,13 @@ int console_register(struct console_device *newcdev) ret = newcdev->setbrg(newcdev, baudrate); if (ret) return ret; - newcdev->baudrate_param = newcdev->baudrate = baudrate; + newcdev->baudrate_param = baudrate; dev_add_param_uint32(dev, "baudrate", console_baudrate_set, NULL, &newcdev->baudrate_param, "%u", newcdev); } + newcdev->baudrate = baudrate; + if (newcdev->putc && !newcdev->puts) newcdev->puts = __console_puts; |