Browse Source

tty/serial: at91: correct check of buf used in DMA

We only use buf of ring In DMA rx function while using buf of xmit
in DMA tx function. So in DMA rx we need definitively to check the
buf of ring which is corresponding to DMA rx function. And use macro
PAGE_ALIGNED to simplify the expression.

Signed-off-by: Leilei Zhao <leilei.zhao@atmel.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Leilei Zhao 10 years ago
parent
commit
2c27705410
1 changed files with 2 additions and 2 deletions
  1. 2 2
      drivers/tty/serial/atmel_serial.c

+ 2 - 2
drivers/tty/serial/atmel_serial.c

@@ -848,7 +848,7 @@ static int atmel_prepare_tx_dma(struct uart_port *port)
 	spin_lock_init(&atmel_port->lock_tx);
 	spin_lock_init(&atmel_port->lock_tx);
 	sg_init_table(&atmel_port->sg_tx, 1);
 	sg_init_table(&atmel_port->sg_tx, 1);
 	/* UART circular tx buffer is an aligned page. */
 	/* UART circular tx buffer is an aligned page. */
-	BUG_ON((int)port->state->xmit.buf & ~PAGE_MASK);
+	BUG_ON(!PAGE_ALIGNED(port->state->xmit.buf));
 	sg_set_page(&atmel_port->sg_tx,
 	sg_set_page(&atmel_port->sg_tx,
 			virt_to_page(port->state->xmit.buf),
 			virt_to_page(port->state->xmit.buf),
 			UART_XMIT_SIZE,
 			UART_XMIT_SIZE,
@@ -1027,7 +1027,7 @@ static int atmel_prepare_rx_dma(struct uart_port *port)
 	spin_lock_init(&atmel_port->lock_rx);
 	spin_lock_init(&atmel_port->lock_rx);
 	sg_init_table(&atmel_port->sg_rx, 1);
 	sg_init_table(&atmel_port->sg_rx, 1);
 	/* UART circular rx buffer is an aligned page. */
 	/* UART circular rx buffer is an aligned page. */
-	BUG_ON((int)port->state->xmit.buf & ~PAGE_MASK);
+	BUG_ON(!PAGE_ALIGNED(ring->buf));
 	sg_set_page(&atmel_port->sg_rx,
 	sg_set_page(&atmel_port->sg_rx,
 		    virt_to_page(ring->buf),
 		    virt_to_page(ring->buf),
 		    ATMEL_SERIAL_RINGSIZE,
 		    ATMEL_SERIAL_RINGSIZE,