@@ -1492,18 +1492,25 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
struct uart_amba_port *uap = (struct uart_amba_port *)port;
unsigned int lcr_h, old_cr;
unsigned long flags;
- unsigned int baud, quot, clkdiv;
+ unsigned int max_baud, baud, quot;
if (uap->vendor->oversampling)
- clkdiv = 8;
+ max_baud = port->uartclk / 8;
else
- clkdiv = 16;
+ max_baud = port->uartclk / 16;
+
+ if ((termios->c_ispeed > max_baud) ||
+ (termios->c_ospeed > max_baud)) {
+ dev_err(port->dev,
+ "requested a baud rate > clock/mindivisor\n");
+ return;
+ }
/*
* Ask the core to calculate the divisor for us.
*/
baud = uart_get_baud_rate(port, termios, old, 0,
- port->uartclk / clkdiv);
+ max_baud);
if (baud > port->uartclk/16)
quot = DIV_ROUND_CLOSEST(port->uartclk * 8, baud);