summaryrefslogtreecommitdiff
path: root/sys/dev/uart/uart_subr.c
diff options
context:
space:
mode:
authorMarcel Moolenaar <marcel@FreeBSD.org>2004-11-14 21:38:22 +0000
committerMarcel Moolenaar <marcel@FreeBSD.org>2004-11-14 21:38:22 +0000
commitecf4dc2505b4a9f5e98e66f7a09614ce22441297 (patch)
treec4469ae5d1cacc8dbd1f933295b017658882c8ad /sys/dev/uart/uart_subr.c
parent443ceb1c7efdfe3ca9476c719656db0f38a7e374 (diff)
Notes
Diffstat (limited to 'sys/dev/uart/uart_subr.c')
-rw-r--r--sys/dev/uart/uart_subr.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/sys/dev/uart/uart_subr.c b/sys/dev/uart/uart_subr.c
index 4c40a3613ba5..27dfd41b0735 100644
--- a/sys/dev/uart/uart_subr.c
+++ b/sys/dev/uart/uart_subr.c
@@ -242,6 +242,26 @@ uart_getenv(int devtype, struct uart_devinfo *di)
*/
if (addr == ~0U)
return (EINVAL);
+
+ /*
+ * Accept only the well-known baudrates. Any invalid baudrate
+ * is silently replaced with a 0-valued baudrate. The 0 baudrate
+ * has special meaning. It means that we're not supposed to
+ * program the baudrate and simply communicate with whatever
+ * speed the hardware is currently programmed for.
+ */
+ if (di->baudrate >= 19200) {
+ if (di->baudrate % 19200)
+ di->baudrate = 0;
+ } else if (di->baudrate >= 1200) {
+ if (di->baudrate % 1200)
+ di->baudrate = 0;
+ } else if (di->baudrate > 0) {
+ if (di->baudrate % 75)
+ di->baudrate = 0;
+ } else
+ di->baudrate = 0;
+
/* XXX the size of the mapping depends on the UART class. */
if (bus_space_map(di->bas.bst, addr, 8, 0, &di->bas.bsh) != 0)
return (EINVAL);