[PATCH v2 REBASED 02/10] serial/arc: Refactor by referencing to uart_port where possible

2014-06-24 Thread Vineet Gupta
The ARC UART MMIO helpers would take arc_uart_port and then reference
generic uart_port->membase member. So change them to difrectly refer to
uart_port and fix call sites accordingly.

This removes the need for to_arc_port() converion almost eveeywhere and
makes code a bit easier to read.

Signed-off-by: Vineet Gupta 
---
 drivers/tty/serial/arc_uart.c | 155 +++---
 1 file changed, 69 insertions(+), 86 deletions(-)

diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 32fb8b94ff7c..4d971281e3d9 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -72,7 +72,7 @@
 #define RXOERR  0x02   /* OverFlow Err: Char recv but RXFULL still set */
 
 /* Uart bit fiddling helpers: lowest level */
-#define RBASE(uart, reg)  (uart->port.membase + reg)
+#define RBASE(port, reg)  (port->membase + reg)
 #define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r))
 #define UART_REG_GET(u, r)readb(RBASE(u, r))
 
@@ -129,19 +129,15 @@ static struct uart_driver arc_uart_driver = {
 
 static void arc_serial_stop_rx(struct uart_port *port)
 {
-   struct arc_uart_port *uart = to_arc_port(port);
-
-   UART_RX_IRQ_DISABLE(uart);
+   UART_RX_IRQ_DISABLE(port);
 }
 
 static void arc_serial_stop_tx(struct uart_port *port)
 {
-   struct arc_uart_port *uart = to_arc_port(port);
-
-   while (!(UART_GET_STATUS(uart) & TXEMPTY))
+   while (!(UART_GET_STATUS(port) & TXEMPTY))
cpu_relax();
 
-   UART_TX_IRQ_DISABLE(uart);
+   UART_TX_IRQ_DISABLE(port);
 }
 
 /*
@@ -149,10 +145,9 @@ static void arc_serial_stop_tx(struct uart_port *port)
  */
 static unsigned int arc_serial_tx_empty(struct uart_port *port)
 {
-   struct arc_uart_port *uart = to_arc_port(port);
unsigned int stat;
 
-   stat = UART_GET_STATUS(uart);
+   stat = UART_GET_STATUS(port);
if (stat & TXEMPTY)
return TIOCSER_TEMT;
 
@@ -166,24 +161,24 @@ static unsigned int arc_serial_tx_empty(struct uart_port 
*port)
  * = by uart_start( ) before calling us
  * = tx_ist checks that too before calling
  */
-static void arc_serial_tx_chars(struct arc_uart_port *uart)
+static void arc_serial_tx_chars(struct uart_port *port)
 {
-   struct circ_buf *xmit = >port.state->xmit;
+   struct circ_buf *xmit = >state->xmit;
int sent = 0;
unsigned char ch;
 
-   if (unlikely(uart->port.x_char)) {
-   UART_SET_DATA(uart, uart->port.x_char);
-   uart->port.icount.tx++;
-   uart->port.x_char = 0;
+   if (unlikely(port->x_char)) {
+   UART_SET_DATA(port, port->x_char);
+   port->icount.tx++;
+   port->x_char = 0;
sent = 1;
} else if (xmit->tail != xmit->head) {  /* TODO: uart_circ_empty */
ch = xmit->buf[xmit->tail];
xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
-   uart->port.icount.tx++;
-   while (!(UART_GET_STATUS(uart) & TXEMPTY))
+   port->icount.tx++;
+   while (!(UART_GET_STATUS(port) & TXEMPTY))
cpu_relax();
-   UART_SET_DATA(uart, ch);
+   UART_SET_DATA(port, ch);
sent = 1;
}
 
@@ -192,10 +187,10 @@ static void arc_serial_tx_chars(struct arc_uart_port 
*uart)
 * By Hard ISR to schedule processing in software interrupt part
 */
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
-   uart_write_wakeup(>port);
+   uart_write_wakeup(port);
 
if (sent)
-   UART_TX_IRQ_ENABLE(uart);
+   UART_TX_IRQ_ENABLE(port);
 }
 
 /*
@@ -204,12 +199,10 @@ static void arc_serial_tx_chars(struct arc_uart_port 
*uart)
  */
 static void arc_serial_start_tx(struct uart_port *port)
 {
-   struct arc_uart_port *uart = to_arc_port(port);
-
-   arc_serial_tx_chars(uart);
+   arc_serial_tx_chars(port);
 }
 
-static void arc_serial_rx_chars(struct arc_uart_port *uart, unsigned int 
status)
+static void arc_serial_rx_chars(struct uart_port *port, unsigned int status)
 {
unsigned int ch, flg = 0;
 
@@ -229,15 +222,15 @@ static void arc_serial_rx_chars(struct arc_uart_port 
*uart, unsigned int status)
 */
if (unlikely(status & (RXOERR | RXFERR))) {
if (status & RXOERR) {
-   uart->port.icount.overrun++;
+   port->icount.overrun++;
flg = TTY_OVERRUN;
-   UART_CLR_STATUS(uart, RXOERR);
+   UART_CLR_STATUS(port, RXOERR);
}
 
if (status & RXFERR) {
-   uart->port.icount.frame++;
+   port->icount.frame++;
flg = TTY_FRAME;
-  

[PATCH v2 REBASED 02/10] serial/arc: Refactor by referencing to uart_port where possible

2014-06-24 Thread Vineet Gupta
The ARC UART MMIO helpers would take arc_uart_port and then reference
generic uart_port-membase member. So change them to difrectly refer to
uart_port and fix call sites accordingly.

This removes the need for to_arc_port() converion almost eveeywhere and
makes code a bit easier to read.

Signed-off-by: Vineet Gupta vgu...@synopsys.com
---
 drivers/tty/serial/arc_uart.c | 155 +++---
 1 file changed, 69 insertions(+), 86 deletions(-)

diff --git a/drivers/tty/serial/arc_uart.c b/drivers/tty/serial/arc_uart.c
index 32fb8b94ff7c..4d971281e3d9 100644
--- a/drivers/tty/serial/arc_uart.c
+++ b/drivers/tty/serial/arc_uart.c
@@ -72,7 +72,7 @@
 #define RXOERR  0x02   /* OverFlow Err: Char recv but RXFULL still set */
 
 /* Uart bit fiddling helpers: lowest level */
-#define RBASE(uart, reg)  (uart-port.membase + reg)
+#define RBASE(port, reg)  (port-membase + reg)
 #define UART_REG_SET(u, r, v) writeb((v), RBASE(u, r))
 #define UART_REG_GET(u, r)readb(RBASE(u, r))
 
@@ -129,19 +129,15 @@ static struct uart_driver arc_uart_driver = {
 
 static void arc_serial_stop_rx(struct uart_port *port)
 {
-   struct arc_uart_port *uart = to_arc_port(port);
-
-   UART_RX_IRQ_DISABLE(uart);
+   UART_RX_IRQ_DISABLE(port);
 }
 
 static void arc_serial_stop_tx(struct uart_port *port)
 {
-   struct arc_uart_port *uart = to_arc_port(port);
-
-   while (!(UART_GET_STATUS(uart)  TXEMPTY))
+   while (!(UART_GET_STATUS(port)  TXEMPTY))
cpu_relax();
 
-   UART_TX_IRQ_DISABLE(uart);
+   UART_TX_IRQ_DISABLE(port);
 }
 
 /*
@@ -149,10 +145,9 @@ static void arc_serial_stop_tx(struct uart_port *port)
  */
 static unsigned int arc_serial_tx_empty(struct uart_port *port)
 {
-   struct arc_uart_port *uart = to_arc_port(port);
unsigned int stat;
 
-   stat = UART_GET_STATUS(uart);
+   stat = UART_GET_STATUS(port);
if (stat  TXEMPTY)
return TIOCSER_TEMT;
 
@@ -166,24 +161,24 @@ static unsigned int arc_serial_tx_empty(struct uart_port 
*port)
  * = by uart_start( ) before calling us
  * = tx_ist checks that too before calling
  */
-static void arc_serial_tx_chars(struct arc_uart_port *uart)
+static void arc_serial_tx_chars(struct uart_port *port)
 {
-   struct circ_buf *xmit = uart-port.state-xmit;
+   struct circ_buf *xmit = port-state-xmit;
int sent = 0;
unsigned char ch;
 
-   if (unlikely(uart-port.x_char)) {
-   UART_SET_DATA(uart, uart-port.x_char);
-   uart-port.icount.tx++;
-   uart-port.x_char = 0;
+   if (unlikely(port-x_char)) {
+   UART_SET_DATA(port, port-x_char);
+   port-icount.tx++;
+   port-x_char = 0;
sent = 1;
} else if (xmit-tail != xmit-head) {  /* TODO: uart_circ_empty */
ch = xmit-buf[xmit-tail];
xmit-tail = (xmit-tail + 1)  (UART_XMIT_SIZE - 1);
-   uart-port.icount.tx++;
-   while (!(UART_GET_STATUS(uart)  TXEMPTY))
+   port-icount.tx++;
+   while (!(UART_GET_STATUS(port)  TXEMPTY))
cpu_relax();
-   UART_SET_DATA(uart, ch);
+   UART_SET_DATA(port, ch);
sent = 1;
}
 
@@ -192,10 +187,10 @@ static void arc_serial_tx_chars(struct arc_uart_port 
*uart)
 * By Hard ISR to schedule processing in software interrupt part
 */
if (uart_circ_chars_pending(xmit)  WAKEUP_CHARS)
-   uart_write_wakeup(uart-port);
+   uart_write_wakeup(port);
 
if (sent)
-   UART_TX_IRQ_ENABLE(uart);
+   UART_TX_IRQ_ENABLE(port);
 }
 
 /*
@@ -204,12 +199,10 @@ static void arc_serial_tx_chars(struct arc_uart_port 
*uart)
  */
 static void arc_serial_start_tx(struct uart_port *port)
 {
-   struct arc_uart_port *uart = to_arc_port(port);
-
-   arc_serial_tx_chars(uart);
+   arc_serial_tx_chars(port);
 }
 
-static void arc_serial_rx_chars(struct arc_uart_port *uart, unsigned int 
status)
+static void arc_serial_rx_chars(struct uart_port *port, unsigned int status)
 {
unsigned int ch, flg = 0;
 
@@ -229,15 +222,15 @@ static void arc_serial_rx_chars(struct arc_uart_port 
*uart, unsigned int status)
 */
if (unlikely(status  (RXOERR | RXFERR))) {
if (status  RXOERR) {
-   uart-port.icount.overrun++;
+   port-icount.overrun++;
flg = TTY_OVERRUN;
-   UART_CLR_STATUS(uart, RXOERR);
+   UART_CLR_STATUS(port, RXOERR);
}
 
if (status  RXFERR) {
-   uart-port.icount.frame++;
+   port-icount.frame++;
flg = TTY_FRAME;
-