提交 dfe42443 编写于 作者: P Paul Gortmaker 提交者: Greg Kroah-Hartman

serial: reduce number of indirections in 8250 code

The serial_8250_port struct contains within a serial_port struct
and many times one or the other, or both are in scope within
functions via a passed in arg, or via container_of.

However there are a lot of cases where we have access directly
to the port pointer, but yet go through the parent 8250_port
structure instead to get it.  These should just use the port
struct directly.

Similarly there are cases where it makes sense (from a code
cleanliness point of view) to declare a local for the port
struct, so we aren't going through the parent 8250_port struct
repeatedly to get to it.

We get a small reduction in text size, but it appears that
gcc was smart enough to internally be doing most of this
already, so the readability improvement is the larger gain.
Signed-off-by: NPaul Gortmaker <paul.gortmaker@windriver.com>
Acked-by: NAlan Cox <alan@linux.intel.com>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 0d263a26
...@@ -1040,24 +1040,25 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) ...@@ -1040,24 +1040,25 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
{ {
unsigned char status1, scratch, scratch2, scratch3; unsigned char status1, scratch, scratch2, scratch3;
unsigned char save_lcr, save_mcr; unsigned char save_lcr, save_mcr;
struct uart_port *port = &up->port;
unsigned long flags; unsigned long flags;
if (!up->port.iobase && !up->port.mapbase && !up->port.membase) if (!port->iobase && !port->mapbase && !port->membase)
return; return;
DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04lx, 0x%p): ", DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04lx, 0x%p): ",
serial_index(&up->port), up->port.iobase, up->port.membase); serial_index(port), port->iobase, port->membase);
/* /*
* We really do need global IRQs disabled here - we're going to * We really do need global IRQs disabled here - we're going to
* be frobbing the chips IRQ enable register to see if it exists. * be frobbing the chips IRQ enable register to see if it exists.
*/ */
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&port->lock, flags);
up->capabilities = 0; up->capabilities = 0;
up->bugs = 0; up->bugs = 0;
if (!(up->port.flags & UPF_BUGGY_UART)) { if (!(port->flags & UPF_BUGGY_UART)) {
/* /*
* Do a simple existence test first; if we fail this, * Do a simple existence test first; if we fail this,
* there's no point trying anything else. * there's no point trying anything else.
...@@ -1109,7 +1110,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) ...@@ -1109,7 +1110,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
* manufacturer would be stupid enough to design a board * manufacturer would be stupid enough to design a board
* that conflicts with COM 1-4 --- we hope! * that conflicts with COM 1-4 --- we hope!
*/ */
if (!(up->port.flags & UPF_SKIP_TEST)) { if (!(port->flags & UPF_SKIP_TEST)) {
serial_out(up, UART_MCR, UART_MCR_LOOP | 0x0A); serial_out(up, UART_MCR, UART_MCR_LOOP | 0x0A);
status1 = serial_in(up, UART_MSR) & 0xF0; status1 = serial_in(up, UART_MSR) & 0xF0;
serial_out(up, UART_MCR, save_mcr); serial_out(up, UART_MCR, save_mcr);
...@@ -1143,10 +1144,10 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) ...@@ -1143,10 +1144,10 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
autoconfig_8250(up); autoconfig_8250(up);
break; break;
case 1: case 1:
up->port.type = PORT_UNKNOWN; port->type = PORT_UNKNOWN;
break; break;
case 2: case 2:
up->port.type = PORT_16550; port->type = PORT_16550;
break; break;
case 3: case 3:
autoconfig_16550a(up); autoconfig_16550a(up);
...@@ -1157,13 +1158,12 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) ...@@ -1157,13 +1158,12 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
/* /*
* Only probe for RSA ports if we got the region. * Only probe for RSA ports if we got the region.
*/ */
if (up->port.type == PORT_16550A && probeflags & PROBE_RSA) { if (port->type == PORT_16550A && probeflags & PROBE_RSA) {
int i; int i;
for (i = 0 ; i < probe_rsa_count; ++i) { for (i = 0 ; i < probe_rsa_count; ++i) {
if (probe_rsa[i] == up->port.iobase && if (probe_rsa[i] == port->iobase && __enable_rsa(up)) {
__enable_rsa(up)) { port->type = PORT_RSA;
up->port.type = PORT_RSA;
break; break;
} }
} }
...@@ -1172,25 +1172,25 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) ...@@ -1172,25 +1172,25 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
serial_out(up, UART_LCR, save_lcr); serial_out(up, UART_LCR, save_lcr);
if (up->capabilities != uart_config[up->port.type].flags) { if (up->capabilities != uart_config[port->type].flags) {
printk(KERN_WARNING printk(KERN_WARNING
"ttyS%d: detected caps %08x should be %08x\n", "ttyS%d: detected caps %08x should be %08x\n",
serial_index(&up->port), up->capabilities, serial_index(port), up->capabilities,
uart_config[up->port.type].flags); uart_config[port->type].flags);
} }
up->port.fifosize = uart_config[up->port.type].fifo_size; port->fifosize = uart_config[up->port.type].fifo_size;
up->capabilities = uart_config[up->port.type].flags; up->capabilities = uart_config[port->type].flags;
up->tx_loadsz = uart_config[up->port.type].tx_loadsz; up->tx_loadsz = uart_config[port->type].tx_loadsz;
if (up->port.type == PORT_UNKNOWN) if (port->type == PORT_UNKNOWN)
goto out; goto out;
/* /*
* Reset the UART. * Reset the UART.
*/ */
#ifdef CONFIG_SERIAL_8250_RSA #ifdef CONFIG_SERIAL_8250_RSA
if (up->port.type == PORT_RSA) if (port->type == PORT_RSA)
serial_out(up, UART_RSA_FRR, 0); serial_out(up, UART_RSA_FRR, 0);
#endif #endif
serial_out(up, UART_MCR, save_mcr); serial_out(up, UART_MCR, save_mcr);
...@@ -1202,20 +1202,21 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags) ...@@ -1202,20 +1202,21 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
serial_out(up, UART_IER, 0); serial_out(up, UART_IER, 0);
out: out:
spin_unlock_irqrestore(&up->port.lock, flags); spin_unlock_irqrestore(&port->lock, flags);
DEBUG_AUTOCONF("type=%s\n", uart_config[up->port.type].name); DEBUG_AUTOCONF("type=%s\n", uart_config[port->type].name);
} }
static void autoconfig_irq(struct uart_8250_port *up) static void autoconfig_irq(struct uart_8250_port *up)
{ {
struct uart_port *port = &up->port;
unsigned char save_mcr, save_ier; unsigned char save_mcr, save_ier;
unsigned char save_ICP = 0; unsigned char save_ICP = 0;
unsigned int ICP = 0; unsigned int ICP = 0;
unsigned long irqs; unsigned long irqs;
int irq; int irq;
if (up->port.flags & UPF_FOURPORT) { if (port->flags & UPF_FOURPORT) {
ICP = (up->port.iobase & 0xfe0) | 0x1f; ICP = (port->iobase & 0xfe0) | 0x1f;
save_ICP = inb_p(ICP); save_ICP = inb_p(ICP);
outb_p(0x80, ICP); outb_p(0x80, ICP);
inb_p(ICP); inb_p(ICP);
...@@ -1230,7 +1231,7 @@ static void autoconfig_irq(struct uart_8250_port *up) ...@@ -1230,7 +1231,7 @@ static void autoconfig_irq(struct uart_8250_port *up)
irqs = probe_irq_on(); irqs = probe_irq_on();
serial_out(up, UART_MCR, 0); serial_out(up, UART_MCR, 0);
udelay(10); udelay(10);
if (up->port.flags & UPF_FOURPORT) { if (port->flags & UPF_FOURPORT) {
serial_out(up, UART_MCR, serial_out(up, UART_MCR,
UART_MCR_DTR | UART_MCR_RTS); UART_MCR_DTR | UART_MCR_RTS);
} else { } else {
...@@ -1249,10 +1250,10 @@ static void autoconfig_irq(struct uart_8250_port *up) ...@@ -1249,10 +1250,10 @@ static void autoconfig_irq(struct uart_8250_port *up)
serial_out(up, UART_MCR, save_mcr); serial_out(up, UART_MCR, save_mcr);
serial_out(up, UART_IER, save_ier); serial_out(up, UART_IER, save_ier);
if (up->port.flags & UPF_FOURPORT) if (port->flags & UPF_FOURPORT)
outb_p(save_ICP, ICP); outb_p(save_ICP, ICP);
up->port.irq = (irq > 0) ? irq : 0; port->irq = (irq > 0) ? irq : 0;
} }
static inline void __stop_tx(struct uart_8250_port *p) static inline void __stop_tx(struct uart_8250_port *p)
...@@ -1273,7 +1274,7 @@ static void serial8250_stop_tx(struct uart_port *port) ...@@ -1273,7 +1274,7 @@ static void serial8250_stop_tx(struct uart_port *port)
/* /*
* We really want to stop the transmitter from sending. * We really want to stop the transmitter from sending.
*/ */
if (up->port.type == PORT_16C950) { if (port->type == PORT_16C950) {
up->acr |= UART_ACR_TXDIS; up->acr |= UART_ACR_TXDIS;
serial_icr_write(up, UART_ACR, up->acr); serial_icr_write(up, UART_ACR, up->acr);
} }
...@@ -1292,7 +1293,7 @@ static void serial8250_start_tx(struct uart_port *port) ...@@ -1292,7 +1293,7 @@ static void serial8250_start_tx(struct uart_port *port)
unsigned char lsr; unsigned char lsr;
lsr = serial_in(up, UART_LSR); lsr = serial_in(up, UART_LSR);
up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
if ((up->port.type == PORT_RM9000) ? if ((port->type == PORT_RM9000) ?
(lsr & UART_LSR_THRE) : (lsr & UART_LSR_THRE) :
(lsr & UART_LSR_TEMT)) (lsr & UART_LSR_TEMT))
serial8250_tx_chars(up); serial8250_tx_chars(up);
...@@ -1302,7 +1303,7 @@ static void serial8250_start_tx(struct uart_port *port) ...@@ -1302,7 +1303,7 @@ static void serial8250_start_tx(struct uart_port *port)
/* /*
* Re-enable the transmitter if we disabled it. * Re-enable the transmitter if we disabled it.
*/ */
if (up->port.type == PORT_16C950 && up->acr & UART_ACR_TXDIS) { if (port->type == PORT_16C950 && up->acr & UART_ACR_TXDIS) {
up->acr &= ~UART_ACR_TXDIS; up->acr &= ~UART_ACR_TXDIS;
serial_icr_write(up, UART_ACR, up->acr); serial_icr_write(up, UART_ACR, up->acr);
} }
...@@ -1360,7 +1361,8 @@ static void clear_rx_fifo(struct uart_8250_port *up) ...@@ -1360,7 +1361,8 @@ static void clear_rx_fifo(struct uart_8250_port *up)
unsigned char unsigned char
serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
{ {
struct tty_struct *tty = up->port.state->port.tty; struct uart_port *port = &up->port;
struct tty_struct *tty = port->state->port.tty;
unsigned char ch; unsigned char ch;
int max_count = 256; int max_count = 256;
char flag; char flag;
...@@ -1379,7 +1381,7 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) ...@@ -1379,7 +1381,7 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
ch = 0; ch = 0;
flag = TTY_NORMAL; flag = TTY_NORMAL;
up->port.icount.rx++; port->icount.rx++;
lsr |= up->lsr_saved_flags; lsr |= up->lsr_saved_flags;
up->lsr_saved_flags = 0; up->lsr_saved_flags = 0;
...@@ -1390,12 +1392,12 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) ...@@ -1390,12 +1392,12 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
*/ */
if (lsr & UART_LSR_BI) { if (lsr & UART_LSR_BI) {
lsr &= ~(UART_LSR_FE | UART_LSR_PE); lsr &= ~(UART_LSR_FE | UART_LSR_PE);
up->port.icount.brk++; port->icount.brk++;
/* /*
* If tegra port then clear the rx fifo to * If tegra port then clear the rx fifo to
* accept another break/character. * accept another break/character.
*/ */
if (up->port.type == PORT_TEGRA) if (port->type == PORT_TEGRA)
clear_rx_fifo(up); clear_rx_fifo(up);
/* /*
...@@ -1404,19 +1406,19 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) ...@@ -1404,19 +1406,19 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
* may get masked by ignore_status_mask * may get masked by ignore_status_mask
* or read_status_mask. * or read_status_mask.
*/ */
if (uart_handle_break(&up->port)) if (uart_handle_break(port))
goto ignore_char; goto ignore_char;
} else if (lsr & UART_LSR_PE) } else if (lsr & UART_LSR_PE)
up->port.icount.parity++; port->icount.parity++;
else if (lsr & UART_LSR_FE) else if (lsr & UART_LSR_FE)
up->port.icount.frame++; port->icount.frame++;
if (lsr & UART_LSR_OE) if (lsr & UART_LSR_OE)
up->port.icount.overrun++; port->icount.overrun++;
/* /*
* Mask off conditions which should be ignored. * Mask off conditions which should be ignored.
*/ */
lsr &= up->port.read_status_mask; lsr &= port->read_status_mask;
if (lsr & UART_LSR_BI) { if (lsr & UART_LSR_BI) {
DEBUG_INTR("handling break...."); DEBUG_INTR("handling break....");
...@@ -1426,34 +1428,35 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) ...@@ -1426,34 +1428,35 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
else if (lsr & UART_LSR_FE) else if (lsr & UART_LSR_FE)
flag = TTY_FRAME; flag = TTY_FRAME;
} }
if (uart_handle_sysrq_char(&up->port, ch)) if (uart_handle_sysrq_char(port, ch))
goto ignore_char; goto ignore_char;
uart_insert_char(&up->port, lsr, UART_LSR_OE, ch, flag); uart_insert_char(port, lsr, UART_LSR_OE, ch, flag);
ignore_char: ignore_char:
lsr = serial_in(up, UART_LSR); lsr = serial_in(up, UART_LSR);
} while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0));
spin_unlock(&up->port.lock); spin_unlock(&port->lock);
tty_flip_buffer_push(tty); tty_flip_buffer_push(tty);
spin_lock(&up->port.lock); spin_lock(&port->lock);
return lsr; return lsr;
} }
EXPORT_SYMBOL_GPL(serial8250_rx_chars); EXPORT_SYMBOL_GPL(serial8250_rx_chars);
void serial8250_tx_chars(struct uart_8250_port *up) void serial8250_tx_chars(struct uart_8250_port *up)
{ {
struct circ_buf *xmit = &up->port.state->xmit; struct uart_port *port = &up->port;
struct circ_buf *xmit = &port->state->xmit;
int count; int count;
if (up->port.x_char) { if (port->x_char) {
serial_out(up, UART_TX, up->port.x_char); serial_out(up, UART_TX, port->x_char);
up->port.icount.tx++; port->icount.tx++;
up->port.x_char = 0; port->x_char = 0;
return; return;
} }
if (uart_tx_stopped(&up->port)) { if (uart_tx_stopped(port)) {
serial8250_stop_tx(&up->port); serial8250_stop_tx(port);
return; return;
} }
if (uart_circ_empty(xmit)) { if (uart_circ_empty(xmit)) {
...@@ -1465,13 +1468,13 @@ void serial8250_tx_chars(struct uart_8250_port *up) ...@@ -1465,13 +1468,13 @@ void serial8250_tx_chars(struct uart_8250_port *up)
do { do {
serial_out(up, UART_TX, xmit->buf[xmit->tail]); serial_out(up, UART_TX, xmit->buf[xmit->tail]);
xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
up->port.icount.tx++; port->icount.tx++;
if (uart_circ_empty(xmit)) if (uart_circ_empty(xmit))
break; break;
} while (--count > 0); } while (--count > 0);
if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
uart_write_wakeup(&up->port); uart_write_wakeup(port);
DEBUG_INTR("THRE..."); DEBUG_INTR("THRE...");
...@@ -1482,22 +1485,23 @@ EXPORT_SYMBOL_GPL(serial8250_tx_chars); ...@@ -1482,22 +1485,23 @@ EXPORT_SYMBOL_GPL(serial8250_tx_chars);
unsigned int serial8250_modem_status(struct uart_8250_port *up) unsigned int serial8250_modem_status(struct uart_8250_port *up)
{ {
struct uart_port *port = &up->port;
unsigned int status = serial_in(up, UART_MSR); unsigned int status = serial_in(up, UART_MSR);
status |= up->msr_saved_flags; status |= up->msr_saved_flags;
up->msr_saved_flags = 0; up->msr_saved_flags = 0;
if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI && if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI &&
up->port.state != NULL) { port->state != NULL) {
if (status & UART_MSR_TERI) if (status & UART_MSR_TERI)
up->port.icount.rng++; port->icount.rng++;
if (status & UART_MSR_DDSR) if (status & UART_MSR_DDSR)
up->port.icount.dsr++; port->icount.dsr++;
if (status & UART_MSR_DDCD) if (status & UART_MSR_DDCD)
uart_handle_dcd_change(&up->port, status & UART_MSR_DCD); uart_handle_dcd_change(port, status & UART_MSR_DCD);
if (status & UART_MSR_DCTS) if (status & UART_MSR_DCTS)
uart_handle_cts_change(&up->port, status & UART_MSR_CTS); uart_handle_cts_change(port, status & UART_MSR_CTS);
wake_up_interruptible(&up->port.state->port.delta_msr_wait); wake_up_interruptible(&port->state->port.delta_msr_wait);
} }
return status; return status;
...@@ -1517,7 +1521,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) ...@@ -1517,7 +1521,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
if (iir & UART_IIR_NO_INT) if (iir & UART_IIR_NO_INT)
return 0; return 0;
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&port->lock, flags);
status = serial_in(up, UART_LSR); status = serial_in(up, UART_LSR);
...@@ -1529,7 +1533,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir) ...@@ -1529,7 +1533,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
if (status & UART_LSR_THRE) if (status & UART_LSR_THRE)
serial8250_tx_chars(up); serial8250_tx_chars(up);
spin_unlock_irqrestore(&up->port.lock, flags); spin_unlock_irqrestore(&port->lock, flags);
return 1; return 1;
} }
EXPORT_SYMBOL_GPL(serial8250_handle_irq); EXPORT_SYMBOL_GPL(serial8250_handle_irq);
...@@ -1771,10 +1775,10 @@ static unsigned int serial8250_tx_empty(struct uart_port *port) ...@@ -1771,10 +1775,10 @@ static unsigned int serial8250_tx_empty(struct uart_port *port)
unsigned long flags; unsigned long flags;
unsigned int lsr; unsigned int lsr;
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&port->lock, flags);
lsr = serial_in(up, UART_LSR); lsr = serial_in(up, UART_LSR);
up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
spin_unlock_irqrestore(&up->port.lock, flags); spin_unlock_irqrestore(&port->lock, flags);
return (lsr & BOTH_EMPTY) == BOTH_EMPTY ? TIOCSER_TEMT : 0; return (lsr & BOTH_EMPTY) == BOTH_EMPTY ? TIOCSER_TEMT : 0;
} }
...@@ -1828,13 +1832,13 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state) ...@@ -1828,13 +1832,13 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state)
container_of(port, struct uart_8250_port, port); container_of(port, struct uart_8250_port, port);
unsigned long flags; unsigned long flags;
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&port->lock, flags);
if (break_state == -1) if (break_state == -1)
up->lcr |= UART_LCR_SBC; up->lcr |= UART_LCR_SBC;
else else
up->lcr &= ~UART_LCR_SBC; up->lcr &= ~UART_LCR_SBC;
serial_out(up, UART_LCR, up->lcr); serial_out(up, UART_LCR, up->lcr);
spin_unlock_irqrestore(&up->port.lock, flags); spin_unlock_irqrestore(&port->lock, flags);
} }
/* /*
...@@ -1935,15 +1939,15 @@ static int serial8250_startup(struct uart_port *port) ...@@ -1935,15 +1939,15 @@ static int serial8250_startup(struct uart_port *port)
unsigned char lsr, iir; unsigned char lsr, iir;
int retval; int retval;
up->port.fifosize = uart_config[up->port.type].fifo_size; port->fifosize = uart_config[up->port.type].fifo_size;
up->tx_loadsz = uart_config[up->port.type].tx_loadsz; up->tx_loadsz = uart_config[up->port.type].tx_loadsz;
up->capabilities = uart_config[up->port.type].flags; up->capabilities = uart_config[up->port.type].flags;
up->mcr = 0; up->mcr = 0;
if (up->port.iotype != up->cur_iotype) if (port->iotype != up->cur_iotype)
set_io_from_upio(port); set_io_from_upio(port);
if (up->port.type == PORT_16C950) { if (port->type == PORT_16C950) {
/* Wake up and initialize UART */ /* Wake up and initialize UART */
up->acr = 0; up->acr = 0;
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
...@@ -1983,17 +1987,17 @@ static int serial8250_startup(struct uart_port *port) ...@@ -1983,17 +1987,17 @@ static int serial8250_startup(struct uart_port *port)
* if it is, then bail out, because there's likely no UART * if it is, then bail out, because there's likely no UART
* here. * here.
*/ */
if (!(up->port.flags & UPF_BUGGY_UART) && if (!(port->flags & UPF_BUGGY_UART) &&
(serial_in(up, UART_LSR) == 0xff)) { (serial_in(up, UART_LSR) == 0xff)) {
printk_ratelimited(KERN_INFO "ttyS%d: LSR safety check engaged!\n", printk_ratelimited(KERN_INFO "ttyS%d: LSR safety check engaged!\n",
serial_index(&up->port)); serial_index(port));
return -ENODEV; return -ENODEV;
} }
/* /*
* For a XR16C850, we need to set the trigger levels * For a XR16C850, we need to set the trigger levels
*/ */
if (up->port.type == PORT_16850) { if (port->type == PORT_16850) {
unsigned char fctr; unsigned char fctr;
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
...@@ -2007,7 +2011,7 @@ static int serial8250_startup(struct uart_port *port) ...@@ -2007,7 +2011,7 @@ static int serial8250_startup(struct uart_port *port)
serial_out(up, UART_LCR, 0); serial_out(up, UART_LCR, 0);
} }
if (up->port.irq) { if (port->irq) {
unsigned char iir1; unsigned char iir1;
/* /*
* Test for UARTs that do not reassert THRE when the * Test for UARTs that do not reassert THRE when the
...@@ -2017,9 +2021,9 @@ static int serial8250_startup(struct uart_port *port) ...@@ -2017,9 +2021,9 @@ static int serial8250_startup(struct uart_port *port)
* the interrupt is enabled. Delays are necessary to * the interrupt is enabled. Delays are necessary to
* allow register changes to become visible. * allow register changes to become visible.
*/ */
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&port->lock, flags);
if (up->port.irqflags & IRQF_SHARED) if (up->port.irqflags & IRQF_SHARED)
disable_irq_nosync(up->port.irq); disable_irq_nosync(port->irq);
wait_for_xmitr(up, UART_LSR_THRE); wait_for_xmitr(up, UART_LSR_THRE);
serial_out_sync(up, UART_IER, UART_IER_THRI); serial_out_sync(up, UART_IER, UART_IER_THRI);
...@@ -2031,9 +2035,9 @@ static int serial8250_startup(struct uart_port *port) ...@@ -2031,9 +2035,9 @@ static int serial8250_startup(struct uart_port *port)
iir = serial_in(up, UART_IIR); iir = serial_in(up, UART_IIR);
serial_out(up, UART_IER, 0); serial_out(up, UART_IER, 0);
if (up->port.irqflags & IRQF_SHARED) if (port->irqflags & IRQF_SHARED)
enable_irq(up->port.irq); enable_irq(port->irq);
spin_unlock_irqrestore(&up->port.lock, flags); spin_unlock_irqrestore(&port->lock, flags);
/* /*
* If the interrupt is not reasserted, setup a timer to * If the interrupt is not reasserted, setup a timer to
...@@ -2062,7 +2066,7 @@ static int serial8250_startup(struct uart_port *port) ...@@ -2062,7 +2066,7 @@ static int serial8250_startup(struct uart_port *port)
* hardware interrupt, we use a timer-based system. The original * hardware interrupt, we use a timer-based system. The original
* driver used to do this with IRQ0. * driver used to do this with IRQ0.
*/ */
if (!up->port.irq) { if (!port->irq) {
up->timer.data = (unsigned long)up; up->timer.data = (unsigned long)up;
mod_timer(&up->timer, jiffies + uart_poll_timeout(port)); mod_timer(&up->timer, jiffies + uart_poll_timeout(port));
} else { } else {
...@@ -2076,7 +2080,7 @@ static int serial8250_startup(struct uart_port *port) ...@@ -2076,7 +2080,7 @@ static int serial8250_startup(struct uart_port *port)
*/ */
serial_out(up, UART_LCR, UART_LCR_WLEN8); serial_out(up, UART_LCR, UART_LCR_WLEN8);
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&port->lock, flags);
if (up->port.flags & UPF_FOURPORT) { if (up->port.flags & UPF_FOURPORT) {
if (!up->port.irq) if (!up->port.irq)
up->port.mctrl |= TIOCM_OUT1; up->port.mctrl |= TIOCM_OUT1;
...@@ -2084,10 +2088,10 @@ static int serial8250_startup(struct uart_port *port) ...@@ -2084,10 +2088,10 @@ static int serial8250_startup(struct uart_port *port)
/* /*
* Most PC uarts need OUT2 raised to enable interrupts. * Most PC uarts need OUT2 raised to enable interrupts.
*/ */
if (up->port.irq) if (port->irq)
up->port.mctrl |= TIOCM_OUT2; up->port.mctrl |= TIOCM_OUT2;
serial8250_set_mctrl(&up->port, up->port.mctrl); serial8250_set_mctrl(port, port->mctrl);
/* Serial over Lan (SoL) hack: /* Serial over Lan (SoL) hack:
Intel 8257x Gigabit ethernet chips have a Intel 8257x Gigabit ethernet chips have a
...@@ -2123,7 +2127,7 @@ static int serial8250_startup(struct uart_port *port) ...@@ -2123,7 +2127,7 @@ static int serial8250_startup(struct uart_port *port)
} }
dont_test_tx_en: dont_test_tx_en:
spin_unlock_irqrestore(&up->port.lock, flags); spin_unlock_irqrestore(&port->lock, flags);
/* /*
* Clear the interrupt registers again for luck, and clear the * Clear the interrupt registers again for luck, and clear the
...@@ -2145,12 +2149,12 @@ static int serial8250_startup(struct uart_port *port) ...@@ -2145,12 +2149,12 @@ static int serial8250_startup(struct uart_port *port)
up->ier = UART_IER_RLSI | UART_IER_RDI; up->ier = UART_IER_RLSI | UART_IER_RDI;
serial_out(up, UART_IER, up->ier); serial_out(up, UART_IER, up->ier);
if (up->port.flags & UPF_FOURPORT) { if (port->flags & UPF_FOURPORT) {
unsigned int icp; unsigned int icp;
/* /*
* Enable interrupts on the AST Fourport board * Enable interrupts on the AST Fourport board
*/ */
icp = (up->port.iobase & 0xfe0) | 0x01f; icp = (port->iobase & 0xfe0) | 0x01f;
outb_p(0x80, icp); outb_p(0x80, icp);
inb_p(icp); inb_p(icp);
} }
...@@ -2170,16 +2174,16 @@ static void serial8250_shutdown(struct uart_port *port) ...@@ -2170,16 +2174,16 @@ static void serial8250_shutdown(struct uart_port *port)
up->ier = 0; up->ier = 0;
serial_out(up, UART_IER, 0); serial_out(up, UART_IER, 0);
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&port->lock, flags);
if (up->port.flags & UPF_FOURPORT) { if (port->flags & UPF_FOURPORT) {
/* reset interrupts on the AST Fourport board */ /* reset interrupts on the AST Fourport board */
inb((up->port.iobase & 0xfe0) | 0x1f); inb((port->iobase & 0xfe0) | 0x1f);
up->port.mctrl |= TIOCM_OUT1; port->mctrl |= TIOCM_OUT1;
} else } else
up->port.mctrl &= ~TIOCM_OUT2; port->mctrl &= ~TIOCM_OUT2;
serial8250_set_mctrl(&up->port, up->port.mctrl); serial8250_set_mctrl(port, port->mctrl);
spin_unlock_irqrestore(&up->port.lock, flags); spin_unlock_irqrestore(&port->lock, flags);
/* /*
* Disable break condition and FIFOs * Disable break condition and FIFOs
...@@ -2202,7 +2206,7 @@ static void serial8250_shutdown(struct uart_port *port) ...@@ -2202,7 +2206,7 @@ static void serial8250_shutdown(struct uart_port *port)
del_timer_sync(&up->timer); del_timer_sync(&up->timer);
up->timer.function = serial8250_timeout; up->timer.function = serial8250_timeout;
if (up->port.irq) if (port->irq)
serial_unlink_irq_chain(up); serial_unlink_irq_chain(up);
} }
...@@ -2277,11 +2281,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -2277,11 +2281,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
if (up->bugs & UART_BUG_QUOT && (quot & 0xff) == 0) if (up->bugs & UART_BUG_QUOT && (quot & 0xff) == 0)
quot++; quot++;
if (up->capabilities & UART_CAP_FIFO && up->port.fifosize > 1) { if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) {
if (baud < 2400) if (baud < 2400)
fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1; fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
else else
fcr = uart_config[up->port.type].fcr; fcr = uart_config[port->type].fcr;
} }
/* /*
...@@ -2292,7 +2296,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -2292,7 +2296,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
* have sufficient FIFO entries for the latency of the remote * have sufficient FIFO entries for the latency of the remote
* UART to respond. IOW, at least 32 bytes of FIFO. * UART to respond. IOW, at least 32 bytes of FIFO.
*/ */
if (up->capabilities & UART_CAP_AFE && up->port.fifosize >= 32) { if (up->capabilities & UART_CAP_AFE && port->fifosize >= 32) {
up->mcr &= ~UART_MCR_AFE; up->mcr &= ~UART_MCR_AFE;
if (termios->c_cflag & CRTSCTS) if (termios->c_cflag & CRTSCTS)
up->mcr |= UART_MCR_AFE; up->mcr |= UART_MCR_AFE;
...@@ -2302,40 +2306,40 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -2302,40 +2306,40 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
* Ok, we're now changing the port state. Do it with * Ok, we're now changing the port state. Do it with
* interrupts disabled. * interrupts disabled.
*/ */
spin_lock_irqsave(&up->port.lock, flags); spin_lock_irqsave(&port->lock, flags);
/* /*
* Update the per-port timeout. * Update the per-port timeout.
*/ */
uart_update_timeout(port, termios->c_cflag, baud); uart_update_timeout(port, termios->c_cflag, baud);
up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; port->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
if (termios->c_iflag & INPCK) if (termios->c_iflag & INPCK)
up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
if (termios->c_iflag & (BRKINT | PARMRK)) if (termios->c_iflag & (BRKINT | PARMRK))
up->port.read_status_mask |= UART_LSR_BI; port->read_status_mask |= UART_LSR_BI;
/* /*
* Characteres to ignore * Characteres to ignore
*/ */
up->port.ignore_status_mask = 0; port->ignore_status_mask = 0;
if (termios->c_iflag & IGNPAR) if (termios->c_iflag & IGNPAR)
up->port.ignore_status_mask |= UART_LSR_PE | UART_LSR_FE; port->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
if (termios->c_iflag & IGNBRK) { if (termios->c_iflag & IGNBRK) {
up->port.ignore_status_mask |= UART_LSR_BI; port->ignore_status_mask |= UART_LSR_BI;
/* /*
* If we're ignoring parity and break indicators, * If we're ignoring parity and break indicators,
* ignore overruns too (for real raw support). * ignore overruns too (for real raw support).
*/ */
if (termios->c_iflag & IGNPAR) if (termios->c_iflag & IGNPAR)
up->port.ignore_status_mask |= UART_LSR_OE; port->ignore_status_mask |= UART_LSR_OE;
} }
/* /*
* ignore all characters if CREAD is not set * ignore all characters if CREAD is not set
*/ */
if ((termios->c_cflag & CREAD) == 0) if ((termios->c_cflag & CREAD) == 0)
up->port.ignore_status_mask |= UART_LSR_DR; port->ignore_status_mask |= UART_LSR_DR;
/* /*
* CTS flow control flag and modem status interrupts * CTS flow control flag and modem status interrupts
...@@ -2362,7 +2366,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -2362,7 +2366,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
efr |= UART_EFR_CTS; efr |= UART_EFR_CTS;
serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
if (up->port.flags & UPF_EXAR_EFR) if (port->flags & UPF_EXAR_EFR)
serial_out(up, UART_XR_EFR, efr); serial_out(up, UART_XR_EFR, efr);
else else
serial_out(up, UART_EFR, efr); serial_out(up, UART_EFR, efr);
...@@ -2392,20 +2396,20 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios, ...@@ -2392,20 +2396,20 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
* LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR
* is written without DLAB set, this mode will be disabled. * is written without DLAB set, this mode will be disabled.
*/ */
if (up->port.type == PORT_16750) if (port->type == PORT_16750)
serial_out(up, UART_FCR, fcr); serial_out(up, UART_FCR, fcr);
serial_out(up, UART_LCR, cval); /* reset DLAB */ serial_out(up, UART_LCR, cval); /* reset DLAB */
up->lcr = cval; /* Save LCR */ up->lcr = cval; /* Save LCR */
if (up->port.type != PORT_16750) { if (port->type != PORT_16750) {
if (fcr & UART_FCR_ENABLE_FIFO) { if (fcr & UART_FCR_ENABLE_FIFO) {
/* emulated UARTs (Lucent Venus 167x) need two steps */ /* emulated UARTs (Lucent Venus 167x) need two steps */
serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO);
} }
serial_out(up, UART_FCR, fcr); /* set fcr */ serial_out(up, UART_FCR, fcr); /* set fcr */
} }
serial8250_set_mctrl(&up->port, up->port.mctrl); serial8250_set_mctrl(port, port->mctrl);
spin_unlock_irqrestore(&up->port.lock, flags); spin_unlock_irqrestore(&port->lock, flags);
/* Don't rewrite B0 */ /* Don't rewrite B0 */
if (tty_termios_baud_rate(termios)) if (tty_termios_baud_rate(termios))
tty_termios_encode_baud_rate(termios, baud, baud); tty_termios_encode_baud_rate(termios, baud, baud);
...@@ -2470,26 +2474,26 @@ static unsigned int serial8250_port_size(struct uart_8250_port *pt) ...@@ -2470,26 +2474,26 @@ static unsigned int serial8250_port_size(struct uart_8250_port *pt)
static int serial8250_request_std_resource(struct uart_8250_port *up) static int serial8250_request_std_resource(struct uart_8250_port *up)
{ {
unsigned int size = serial8250_port_size(up); unsigned int size = serial8250_port_size(up);
struct uart_port *port = &up->port;
int ret = 0; int ret = 0;
switch (up->port.iotype) { switch (port->iotype) {
case UPIO_AU: case UPIO_AU:
case UPIO_TSI: case UPIO_TSI:
case UPIO_MEM32: case UPIO_MEM32:
case UPIO_MEM: case UPIO_MEM:
if (!up->port.mapbase) if (!port->mapbase)
break; break;
if (!request_mem_region(up->port.mapbase, size, "serial")) { if (!request_mem_region(port->mapbase, size, "serial")) {
ret = -EBUSY; ret = -EBUSY;
break; break;
} }
if (up->port.flags & UPF_IOREMAP) { if (port->flags & UPF_IOREMAP) {
up->port.membase = ioremap_nocache(up->port.mapbase, port->membase = ioremap_nocache(port->mapbase, size);
size); if (!port->membase) {
if (!up->port.membase) { release_mem_region(port->mapbase, size);
release_mem_region(up->port.mapbase, size);
ret = -ENOMEM; ret = -ENOMEM;
} }
} }
...@@ -2497,7 +2501,7 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) ...@@ -2497,7 +2501,7 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
case UPIO_HUB6: case UPIO_HUB6:
case UPIO_PORT: case UPIO_PORT:
if (!request_region(up->port.iobase, size, "serial")) if (!request_region(port->iobase, size, "serial"))
ret = -EBUSY; ret = -EBUSY;
break; break;
} }
...@@ -2507,26 +2511,27 @@ static int serial8250_request_std_resource(struct uart_8250_port *up) ...@@ -2507,26 +2511,27 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
static void serial8250_release_std_resource(struct uart_8250_port *up) static void serial8250_release_std_resource(struct uart_8250_port *up)
{ {
unsigned int size = serial8250_port_size(up); unsigned int size = serial8250_port_size(up);
struct uart_port *port = &up->port;
switch (up->port.iotype) { switch (port->iotype) {
case UPIO_AU: case UPIO_AU:
case UPIO_TSI: case UPIO_TSI:
case UPIO_MEM32: case UPIO_MEM32:
case UPIO_MEM: case UPIO_MEM:
if (!up->port.mapbase) if (!port->mapbase)
break; break;
if (up->port.flags & UPF_IOREMAP) { if (port->flags & UPF_IOREMAP) {
iounmap(up->port.membase); iounmap(port->membase);
up->port.membase = NULL; port->membase = NULL;
} }
release_mem_region(up->port.mapbase, size); release_mem_region(port->mapbase, size);
break; break;
case UPIO_HUB6: case UPIO_HUB6:
case UPIO_PORT: case UPIO_PORT:
release_region(up->port.iobase, size); release_region(port->iobase, size);
break; break;
} }
} }
...@@ -2535,12 +2540,13 @@ static int serial8250_request_rsa_resource(struct uart_8250_port *up) ...@@ -2535,12 +2540,13 @@ static int serial8250_request_rsa_resource(struct uart_8250_port *up)
{ {
unsigned long start = UART_RSA_BASE << up->port.regshift; unsigned long start = UART_RSA_BASE << up->port.regshift;
unsigned int size = 8 << up->port.regshift; unsigned int size = 8 << up->port.regshift;
struct uart_port *port = &up->port;
int ret = -EINVAL; int ret = -EINVAL;
switch (up->port.iotype) { switch (port->iotype) {
case UPIO_HUB6: case UPIO_HUB6:
case UPIO_PORT: case UPIO_PORT:
start += up->port.iobase; start += port->iobase;
if (request_region(start, size, "serial-rsa")) if (request_region(start, size, "serial-rsa"))
ret = 0; ret = 0;
else else
...@@ -2555,11 +2561,12 @@ static void serial8250_release_rsa_resource(struct uart_8250_port *up) ...@@ -2555,11 +2561,12 @@ static void serial8250_release_rsa_resource(struct uart_8250_port *up)
{ {
unsigned long offset = UART_RSA_BASE << up->port.regshift; unsigned long offset = UART_RSA_BASE << up->port.regshift;
unsigned int size = 8 << up->port.regshift; unsigned int size = 8 << up->port.regshift;
struct uart_port *port = &up->port;
switch (up->port.iotype) { switch (port->iotype) {
case UPIO_HUB6: case UPIO_HUB6:
case UPIO_PORT: case UPIO_PORT:
release_region(up->port.iobase + offset, size); release_region(port->iobase + offset, size);
break; break;
} }
} }
...@@ -2570,7 +2577,7 @@ static void serial8250_release_port(struct uart_port *port) ...@@ -2570,7 +2577,7 @@ static void serial8250_release_port(struct uart_port *port)
container_of(port, struct uart_8250_port, port); container_of(port, struct uart_8250_port, port);
serial8250_release_std_resource(up); serial8250_release_std_resource(up);
if (up->port.type == PORT_RSA) if (port->type == PORT_RSA)
serial8250_release_rsa_resource(up); serial8250_release_rsa_resource(up);
} }
...@@ -2581,7 +2588,7 @@ static int serial8250_request_port(struct uart_port *port) ...@@ -2581,7 +2588,7 @@ static int serial8250_request_port(struct uart_port *port)
int ret = 0; int ret = 0;
ret = serial8250_request_std_resource(up); ret = serial8250_request_std_resource(up);
if (ret == 0 && up->port.type == PORT_RSA) { if (ret == 0 && port->type == PORT_RSA) {
ret = serial8250_request_rsa_resource(up); ret = serial8250_request_rsa_resource(up);
if (ret < 0) if (ret < 0)
serial8250_release_std_resource(up); serial8250_release_std_resource(up);
...@@ -2609,22 +2616,22 @@ static void serial8250_config_port(struct uart_port *port, int flags) ...@@ -2609,22 +2616,22 @@ static void serial8250_config_port(struct uart_port *port, int flags)
if (ret < 0) if (ret < 0)
probeflags &= ~PROBE_RSA; probeflags &= ~PROBE_RSA;
if (up->port.iotype != up->cur_iotype) if (port->iotype != up->cur_iotype)
set_io_from_upio(port); set_io_from_upio(port);
if (flags & UART_CONFIG_TYPE) if (flags & UART_CONFIG_TYPE)
autoconfig(up, probeflags); autoconfig(up, probeflags);
/* if access method is AU, it is a 16550 with a quirk */ /* if access method is AU, it is a 16550 with a quirk */
if (up->port.type == PORT_16550A && up->port.iotype == UPIO_AU) if (port->type == PORT_16550A && port->iotype == UPIO_AU)
up->bugs |= UART_BUG_NOMSR; up->bugs |= UART_BUG_NOMSR;
if (up->port.type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ) if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ)
autoconfig_irq(up); autoconfig_irq(up);
if (up->port.type != PORT_RSA && probeflags & PROBE_RSA) if (port->type != PORT_RSA && probeflags & PROBE_RSA)
serial8250_release_rsa_resource(up); serial8250_release_rsa_resource(up);
if (up->port.type == PORT_UNKNOWN) if (port->type == PORT_UNKNOWN)
serial8250_release_std_resource(up); serial8250_release_std_resource(up);
} }
...@@ -2698,9 +2705,10 @@ static void __init serial8250_isa_init_ports(void) ...@@ -2698,9 +2705,10 @@ static void __init serial8250_isa_init_ports(void)
for (i = 0; i < nr_uarts; i++) { for (i = 0; i < nr_uarts; i++) {
struct uart_8250_port *up = &serial8250_ports[i]; struct uart_8250_port *up = &serial8250_ports[i];
struct uart_port *port = &up->port;
up->port.line = i; port->line = i;
spin_lock_init(&up->port.lock); spin_lock_init(&port->lock);
init_timer(&up->timer); init_timer(&up->timer);
up->timer.function = serial8250_timeout; up->timer.function = serial8250_timeout;
...@@ -2711,7 +2719,7 @@ static void __init serial8250_isa_init_ports(void) ...@@ -2711,7 +2719,7 @@ static void __init serial8250_isa_init_ports(void)
up->mcr_mask = ~ALPHA_KLUDGE_MCR; up->mcr_mask = ~ALPHA_KLUDGE_MCR;
up->mcr_force = ALPHA_KLUDGE_MCR; up->mcr_force = ALPHA_KLUDGE_MCR;
up->port.ops = &serial8250_pops; port->ops = &serial8250_pops;
} }
if (share_irqs) if (share_irqs)
...@@ -2720,17 +2728,19 @@ static void __init serial8250_isa_init_ports(void) ...@@ -2720,17 +2728,19 @@ static void __init serial8250_isa_init_ports(void)
for (i = 0, up = serial8250_ports; for (i = 0, up = serial8250_ports;
i < ARRAY_SIZE(old_serial_port) && i < nr_uarts; i < ARRAY_SIZE(old_serial_port) && i < nr_uarts;
i++, up++) { i++, up++) {
up->port.iobase = old_serial_port[i].port; struct uart_port *port = &up->port;
up->port.irq = irq_canonicalize(old_serial_port[i].irq);
up->port.irqflags = old_serial_port[i].irqflags; port->iobase = old_serial_port[i].port;
up->port.uartclk = old_serial_port[i].baud_base * 16; port->irq = irq_canonicalize(old_serial_port[i].irq);
up->port.flags = old_serial_port[i].flags; port->irqflags = old_serial_port[i].irqflags;
up->port.hub6 = old_serial_port[i].hub6; port->uartclk = old_serial_port[i].baud_base * 16;
up->port.membase = old_serial_port[i].iomem_base; port->flags = old_serial_port[i].flags;
up->port.iotype = old_serial_port[i].io_type; port->hub6 = old_serial_port[i].hub6;
up->port.regshift = old_serial_port[i].iomem_reg_shift; port->membase = old_serial_port[i].iomem_base;
set_io_from_upio(&up->port); port->iotype = old_serial_port[i].io_type;
up->port.irqflags |= irqflag; port->regshift = old_serial_port[i].iomem_reg_shift;
set_io_from_upio(port);
port->irqflags |= irqflag;
if (serial8250_isa_config != NULL) if (serial8250_isa_config != NULL)
serial8250_isa_config(i, &up->port, &up->capabilities); serial8250_isa_config(i, &up->port, &up->capabilities);
...@@ -2791,6 +2801,7 @@ static void ...@@ -2791,6 +2801,7 @@ static void
serial8250_console_write(struct console *co, const char *s, unsigned int count) serial8250_console_write(struct console *co, const char *s, unsigned int count)
{ {
struct uart_8250_port *up = &serial8250_ports[co->index]; struct uart_8250_port *up = &serial8250_ports[co->index];
struct uart_port *port = &up->port;
unsigned long flags; unsigned long flags;
unsigned int ier; unsigned int ier;
int locked = 1; int locked = 1;
...@@ -2798,13 +2809,13 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count) ...@@ -2798,13 +2809,13 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
touch_nmi_watchdog(); touch_nmi_watchdog();
local_irq_save(flags); local_irq_save(flags);
if (up->port.sysrq) { if (port->sysrq) {
/* serial8250_handle_irq() already took the lock */ /* serial8250_handle_irq() already took the lock */
locked = 0; locked = 0;
} else if (oops_in_progress) { } else if (oops_in_progress) {
locked = spin_trylock(&up->port.lock); locked = spin_trylock(&port->lock);
} else } else
spin_lock(&up->port.lock); spin_lock(&port->lock);
/* /*
* First save the IER then disable the interrupts * First save the IER then disable the interrupts
...@@ -2816,7 +2827,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count) ...@@ -2816,7 +2827,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
else else
serial_out(up, UART_IER, 0); serial_out(up, UART_IER, 0);
uart_console_write(&up->port, s, count, serial8250_console_putchar); uart_console_write(port, s, count, serial8250_console_putchar);
/* /*
* Finally, wait for transmitter to become empty * Finally, wait for transmitter to become empty
...@@ -2836,7 +2847,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count) ...@@ -2836,7 +2847,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
serial8250_modem_status(up); serial8250_modem_status(up);
if (locked) if (locked)
spin_unlock(&up->port.lock); spin_unlock(&port->lock);
local_irq_restore(flags); local_irq_restore(flags);
} }
...@@ -2981,6 +2992,7 @@ void serial8250_suspend_port(int line) ...@@ -2981,6 +2992,7 @@ void serial8250_suspend_port(int line)
void serial8250_resume_port(int line) void serial8250_resume_port(int line)
{ {
struct uart_8250_port *up = &serial8250_ports[line]; struct uart_8250_port *up = &serial8250_ports[line];
struct uart_port *port = &up->port;
if (up->capabilities & UART_NATSEMI) { if (up->capabilities & UART_NATSEMI) {
/* Ensure it's still in high speed mode */ /* Ensure it's still in high speed mode */
...@@ -2989,9 +3001,9 @@ void serial8250_resume_port(int line) ...@@ -2989,9 +3001,9 @@ void serial8250_resume_port(int line)
ns16550a_goto_highspeed(up); ns16550a_goto_highspeed(up);
serial_out(up, UART_LCR, 0); serial_out(up, UART_LCR, 0);
up->port.uartclk = 921600*16; port->uartclk = 921600*16;
} }
uart_resume_port(&serial8250_reg, &up->port); uart_resume_port(&serial8250_reg, port);
} }
/* /*
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册