diff options
| author | Marcel Moolenaar <marcel@FreeBSD.org> | 2004-11-20 03:51:21 +0000 |
|---|---|---|
| committer | Marcel Moolenaar <marcel@FreeBSD.org> | 2004-11-20 03:51:21 +0000 |
| commit | 3edeac8a5c392fb14e7351721bc714d799040e2d (patch) | |
| tree | f501a87b7c4729efd0191179fe68e883f83a5314 /sys/dev/uart | |
| parent | 768e58a06fb501b5c5a53eeb9625e90ff39b665a (diff) | |
Notes
Diffstat (limited to 'sys/dev/uart')
| -rw-r--r-- | sys/dev/uart/uart_subr.c | 20 |
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); |
