Merge tag 'lkdtm-next' of https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux...
[linux-2.6-microblaze.git] / drivers / tty / serial / amba-pl011.c
index ba053a6..4d11a3e 100644 (file)
@@ -1255,13 +1255,18 @@ static inline bool pl011_dma_rx_running(struct uart_amba_port *uap)
 
 static void pl011_rs485_tx_stop(struct uart_amba_port *uap)
 {
+       /*
+        * To be on the safe side only time out after twice as many iterations
+        * as fifo size.
+        */
+       const int MAX_TX_DRAIN_ITERS = uap->port.fifosize * 2;
        struct uart_port *port = &uap->port;
        int i = 0;
        u32 cr;
 
        /* Wait until hardware tx queue is empty */
        while (!pl011_tx_empty(port)) {
-               if (i == port->fifosize) {
+               if (i > MAX_TX_DRAIN_ITERS) {
                        dev_warn(port->dev,
                                 "timeout while draining hardware tx queue\n");
                        break;
@@ -2052,7 +2057,7 @@ pl011_set_termios(struct uart_port *port, struct ktermios *termios,
         * with the given baud rate. We use this as the poll interval when we
         * wait for the tx queue to empty.
         */
-       uap->rs485_tx_drain_interval = (bits * 1000 * 1000) / baud;
+       uap->rs485_tx_drain_interval = DIV_ROUND_UP(bits * 1000 * 1000, baud);
 
        pl011_setup_status_masks(port, termios);
 
@@ -2255,7 +2260,7 @@ static struct uart_amba_port *amba_ports[UART_NR];
 
 #ifdef CONFIG_SERIAL_AMBA_PL011_CONSOLE
 
-static void pl011_console_putchar(struct uart_port *port, int ch)
+static void pl011_console_putchar(struct uart_port *port, unsigned char ch)
 {
        struct uart_amba_port *uap =
            container_of(port, struct uart_amba_port, port);
@@ -2471,7 +2476,7 @@ static struct console amba_console = {
 
 #define AMBA_CONSOLE   (&amba_console)
 
-static void qdf2400_e44_putc(struct uart_port *port, int c)
+static void qdf2400_e44_putc(struct uart_port *port, unsigned char c)
 {
        while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
                cpu_relax();
@@ -2487,7 +2492,7 @@ static void qdf2400_e44_early_write(struct console *con, const char *s, unsigned
        uart_console_write(&dev->port, s, n, qdf2400_e44_putc);
 }
 
-static void pl011_putc(struct uart_port *port, int c)
+static void pl011_putc(struct uart_port *port, unsigned char c)
 {
        while (readl(port->membase + UART01x_FR) & UART01x_FR_TXFF)
                cpu_relax();