aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/serial/8250/8250.c
diff options
context:
space:
mode:
authorPaul Gortmaker <paul.gortmaker@windriver.com>2012-03-08 19:12:11 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-09 15:47:56 -0500
commitdfe42443ea1d30c98db59b7b1f914bc147d31336 (patch)
tree479554def3fb2d90592f229e47f06e354aac1e35 /drivers/tty/serial/8250/8250.c
parent0d263a264c4b8376ccf33248f6fac873310e5e05 (diff)
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: Paul Gortmaker <paul.gortmaker@windriver.com> Acked-by: Alan Cox <alan@linux.intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/serial/8250/8250.c')
-rw-r--r--drivers/tty/serial/8250/8250.c322
1 files changed, 167 insertions, 155 deletions
diff --git a/drivers/tty/serial/8250/8250.c b/drivers/tty/serial/8250/8250.c
index 6a71716111ae..a0d114d8baef 100644
--- a/drivers/tty/serial/8250/8250.c
+++ b/drivers/tty/serial/8250/8250.c
@@ -1040,24 +1040,25 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1040{ 1040{
1041 unsigned char status1, scratch, scratch2, scratch3; 1041 unsigned char status1, scratch, scratch2, scratch3;
1042 unsigned char save_lcr, save_mcr; 1042 unsigned char save_lcr, save_mcr;
1043 struct uart_port *port = &up->port;
1043 unsigned long flags; 1044 unsigned long flags;
1044 1045
1045 if (!up->port.iobase && !up->port.mapbase && !up->port.membase) 1046 if (!port->iobase && !port->mapbase && !port->membase)
1046 return; 1047 return;
1047 1048
1048 DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04lx, 0x%p): ", 1049 DEBUG_AUTOCONF("ttyS%d: autoconf (0x%04lx, 0x%p): ",
1049 serial_index(&up->port), up->port.iobase, up->port.membase); 1050 serial_index(port), port->iobase, port->membase);
1050 1051
1051 /* 1052 /*
1052 * We really do need global IRQs disabled here - we're going to 1053 * We really do need global IRQs disabled here - we're going to
1053 * be frobbing the chips IRQ enable register to see if it exists. 1054 * be frobbing the chips IRQ enable register to see if it exists.
1054 */ 1055 */
1055 spin_lock_irqsave(&up->port.lock, flags); 1056 spin_lock_irqsave(&port->lock, flags);
1056 1057
1057 up->capabilities = 0; 1058 up->capabilities = 0;
1058 up->bugs = 0; 1059 up->bugs = 0;
1059 1060
1060 if (!(up->port.flags & UPF_BUGGY_UART)) { 1061 if (!(port->flags & UPF_BUGGY_UART)) {
1061 /* 1062 /*
1062 * Do a simple existence test first; if we fail this, 1063 * Do a simple existence test first; if we fail this,
1063 * there's no point trying anything else. 1064 * there's no point trying anything else.
@@ -1109,7 +1110,7 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1109 * manufacturer would be stupid enough to design a board 1110 * manufacturer would be stupid enough to design a board
1110 * that conflicts with COM 1-4 --- we hope! 1111 * that conflicts with COM 1-4 --- we hope!
1111 */ 1112 */
1112 if (!(up->port.flags & UPF_SKIP_TEST)) { 1113 if (!(port->flags & UPF_SKIP_TEST)) {
1113 serial_out(up, UART_MCR, UART_MCR_LOOP | 0x0A); 1114 serial_out(up, UART_MCR, UART_MCR_LOOP | 0x0A);
1114 status1 = serial_in(up, UART_MSR) & 0xF0; 1115 status1 = serial_in(up, UART_MSR) & 0xF0;
1115 serial_out(up, UART_MCR, save_mcr); 1116 serial_out(up, UART_MCR, save_mcr);
@@ -1143,10 +1144,10 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1143 autoconfig_8250(up); 1144 autoconfig_8250(up);
1144 break; 1145 break;
1145 case 1: 1146 case 1:
1146 up->port.type = PORT_UNKNOWN; 1147 port->type = PORT_UNKNOWN;
1147 break; 1148 break;
1148 case 2: 1149 case 2:
1149 up->port.type = PORT_16550; 1150 port->type = PORT_16550;
1150 break; 1151 break;
1151 case 3: 1152 case 3:
1152 autoconfig_16550a(up); 1153 autoconfig_16550a(up);
@@ -1157,13 +1158,12 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1157 /* 1158 /*
1158 * Only probe for RSA ports if we got the region. 1159 * Only probe for RSA ports if we got the region.
1159 */ 1160 */
1160 if (up->port.type == PORT_16550A && probeflags & PROBE_RSA) { 1161 if (port->type == PORT_16550A && probeflags & PROBE_RSA) {
1161 int i; 1162 int i;
1162 1163
1163 for (i = 0 ; i < probe_rsa_count; ++i) { 1164 for (i = 0 ; i < probe_rsa_count; ++i) {
1164 if (probe_rsa[i] == up->port.iobase && 1165 if (probe_rsa[i] == port->iobase && __enable_rsa(up)) {
1165 __enable_rsa(up)) { 1166 port->type = PORT_RSA;
1166 up->port.type = PORT_RSA;
1167 break; 1167 break;
1168 } 1168 }
1169 } 1169 }
@@ -1172,25 +1172,25 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1172 1172
1173 serial_out(up, UART_LCR, save_lcr); 1173 serial_out(up, UART_LCR, save_lcr);
1174 1174
1175 if (up->capabilities != uart_config[up->port.type].flags) { 1175 if (up->capabilities != uart_config[port->type].flags) {
1176 printk(KERN_WARNING 1176 printk(KERN_WARNING
1177 "ttyS%d: detected caps %08x should be %08x\n", 1177 "ttyS%d: detected caps %08x should be %08x\n",
1178 serial_index(&up->port), up->capabilities, 1178 serial_index(port), up->capabilities,
1179 uart_config[up->port.type].flags); 1179 uart_config[port->type].flags);
1180 } 1180 }
1181 1181
1182 up->port.fifosize = uart_config[up->port.type].fifo_size; 1182 port->fifosize = uart_config[up->port.type].fifo_size;
1183 up->capabilities = uart_config[up->port.type].flags; 1183 up->capabilities = uart_config[port->type].flags;
1184 up->tx_loadsz = uart_config[up->port.type].tx_loadsz; 1184 up->tx_loadsz = uart_config[port->type].tx_loadsz;
1185 1185
1186 if (up->port.type == PORT_UNKNOWN) 1186 if (port->type == PORT_UNKNOWN)
1187 goto out; 1187 goto out;
1188 1188
1189 /* 1189 /*
1190 * Reset the UART. 1190 * Reset the UART.
1191 */ 1191 */
1192#ifdef CONFIG_SERIAL_8250_RSA 1192#ifdef CONFIG_SERIAL_8250_RSA
1193 if (up->port.type == PORT_RSA) 1193 if (port->type == PORT_RSA)
1194 serial_out(up, UART_RSA_FRR, 0); 1194 serial_out(up, UART_RSA_FRR, 0);
1195#endif 1195#endif
1196 serial_out(up, UART_MCR, save_mcr); 1196 serial_out(up, UART_MCR, save_mcr);
@@ -1202,20 +1202,21 @@ static void autoconfig(struct uart_8250_port *up, unsigned int probeflags)
1202 serial_out(up, UART_IER, 0); 1202 serial_out(up, UART_IER, 0);
1203 1203
1204 out: 1204 out:
1205 spin_unlock_irqrestore(&up->port.lock, flags); 1205 spin_unlock_irqrestore(&port->lock, flags);
1206 DEBUG_AUTOCONF("type=%s\n", uart_config[up->port.type].name); 1206 DEBUG_AUTOCONF("type=%s\n", uart_config[port->type].name);
1207} 1207}
1208 1208
1209static void autoconfig_irq(struct uart_8250_port *up) 1209static void autoconfig_irq(struct uart_8250_port *up)
1210{ 1210{
1211 struct uart_port *port = &up->port;
1211 unsigned char save_mcr, save_ier; 1212 unsigned char save_mcr, save_ier;
1212 unsigned char save_ICP = 0; 1213 unsigned char save_ICP = 0;
1213 unsigned int ICP = 0; 1214 unsigned int ICP = 0;
1214 unsigned long irqs; 1215 unsigned long irqs;
1215 int irq; 1216 int irq;
1216 1217
1217 if (up->port.flags & UPF_FOURPORT) { 1218 if (port->flags & UPF_FOURPORT) {
1218 ICP = (up->port.iobase & 0xfe0) | 0x1f; 1219 ICP = (port->iobase & 0xfe0) | 0x1f;
1219 save_ICP = inb_p(ICP); 1220 save_ICP = inb_p(ICP);
1220 outb_p(0x80, ICP); 1221 outb_p(0x80, ICP);
1221 inb_p(ICP); 1222 inb_p(ICP);
@@ -1230,7 +1231,7 @@ static void autoconfig_irq(struct uart_8250_port *up)
1230 irqs = probe_irq_on(); 1231 irqs = probe_irq_on();
1231 serial_out(up, UART_MCR, 0); 1232 serial_out(up, UART_MCR, 0);
1232 udelay(10); 1233 udelay(10);
1233 if (up->port.flags & UPF_FOURPORT) { 1234 if (port->flags & UPF_FOURPORT) {
1234 serial_out(up, UART_MCR, 1235 serial_out(up, UART_MCR,
1235 UART_MCR_DTR | UART_MCR_RTS); 1236 UART_MCR_DTR | UART_MCR_RTS);
1236 } else { 1237 } else {
@@ -1249,10 +1250,10 @@ static void autoconfig_irq(struct uart_8250_port *up)
1249 serial_out(up, UART_MCR, save_mcr); 1250 serial_out(up, UART_MCR, save_mcr);
1250 serial_out(up, UART_IER, save_ier); 1251 serial_out(up, UART_IER, save_ier);
1251 1252
1252 if (up->port.flags & UPF_FOURPORT) 1253 if (port->flags & UPF_FOURPORT)
1253 outb_p(save_ICP, ICP); 1254 outb_p(save_ICP, ICP);
1254 1255
1255 up->port.irq = (irq > 0) ? irq : 0; 1256 port->irq = (irq > 0) ? irq : 0;
1256} 1257}
1257 1258
1258static inline void __stop_tx(struct uart_8250_port *p) 1259static inline void __stop_tx(struct uart_8250_port *p)
@@ -1273,7 +1274,7 @@ static void serial8250_stop_tx(struct uart_port *port)
1273 /* 1274 /*
1274 * We really want to stop the transmitter from sending. 1275 * We really want to stop the transmitter from sending.
1275 */ 1276 */
1276 if (up->port.type == PORT_16C950) { 1277 if (port->type == PORT_16C950) {
1277 up->acr |= UART_ACR_TXDIS; 1278 up->acr |= UART_ACR_TXDIS;
1278 serial_icr_write(up, UART_ACR, up->acr); 1279 serial_icr_write(up, UART_ACR, up->acr);
1279 } 1280 }
@@ -1292,7 +1293,7 @@ static void serial8250_start_tx(struct uart_port *port)
1292 unsigned char lsr; 1293 unsigned char lsr;
1293 lsr = serial_in(up, UART_LSR); 1294 lsr = serial_in(up, UART_LSR);
1294 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; 1295 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
1295 if ((up->port.type == PORT_RM9000) ? 1296 if ((port->type == PORT_RM9000) ?
1296 (lsr & UART_LSR_THRE) : 1297 (lsr & UART_LSR_THRE) :
1297 (lsr & UART_LSR_TEMT)) 1298 (lsr & UART_LSR_TEMT))
1298 serial8250_tx_chars(up); 1299 serial8250_tx_chars(up);
@@ -1302,7 +1303,7 @@ static void serial8250_start_tx(struct uart_port *port)
1302 /* 1303 /*
1303 * Re-enable the transmitter if we disabled it. 1304 * Re-enable the transmitter if we disabled it.
1304 */ 1305 */
1305 if (up->port.type == PORT_16C950 && up->acr & UART_ACR_TXDIS) { 1306 if (port->type == PORT_16C950 && up->acr & UART_ACR_TXDIS) {
1306 up->acr &= ~UART_ACR_TXDIS; 1307 up->acr &= ~UART_ACR_TXDIS;
1307 serial_icr_write(up, UART_ACR, up->acr); 1308 serial_icr_write(up, UART_ACR, up->acr);
1308 } 1309 }
@@ -1360,7 +1361,8 @@ static void clear_rx_fifo(struct uart_8250_port *up)
1360unsigned char 1361unsigned char
1361serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr) 1362serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
1362{ 1363{
1363 struct tty_struct *tty = up->port.state->port.tty; 1364 struct uart_port *port = &up->port;
1365 struct tty_struct *tty = port->state->port.tty;
1364 unsigned char ch; 1366 unsigned char ch;
1365 int max_count = 256; 1367 int max_count = 256;
1366 char flag; 1368 char flag;
@@ -1379,7 +1381,7 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
1379 ch = 0; 1381 ch = 0;
1380 1382
1381 flag = TTY_NORMAL; 1383 flag = TTY_NORMAL;
1382 up->port.icount.rx++; 1384 port->icount.rx++;
1383 1385
1384 lsr |= up->lsr_saved_flags; 1386 lsr |= up->lsr_saved_flags;
1385 up->lsr_saved_flags = 0; 1387 up->lsr_saved_flags = 0;
@@ -1390,12 +1392,12 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
1390 */ 1392 */
1391 if (lsr & UART_LSR_BI) { 1393 if (lsr & UART_LSR_BI) {
1392 lsr &= ~(UART_LSR_FE | UART_LSR_PE); 1394 lsr &= ~(UART_LSR_FE | UART_LSR_PE);
1393 up->port.icount.brk++; 1395 port->icount.brk++;
1394 /* 1396 /*
1395 * If tegra port then clear the rx fifo to 1397 * If tegra port then clear the rx fifo to
1396 * accept another break/character. 1398 * accept another break/character.
1397 */ 1399 */
1398 if (up->port.type == PORT_TEGRA) 1400 if (port->type == PORT_TEGRA)
1399 clear_rx_fifo(up); 1401 clear_rx_fifo(up);
1400 1402
1401 /* 1403 /*
@@ -1404,19 +1406,19 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
1404 * may get masked by ignore_status_mask 1406 * may get masked by ignore_status_mask
1405 * or read_status_mask. 1407 * or read_status_mask.
1406 */ 1408 */
1407 if (uart_handle_break(&up->port)) 1409 if (uart_handle_break(port))
1408 goto ignore_char; 1410 goto ignore_char;
1409 } else if (lsr & UART_LSR_PE) 1411 } else if (lsr & UART_LSR_PE)
1410 up->port.icount.parity++; 1412 port->icount.parity++;
1411 else if (lsr & UART_LSR_FE) 1413 else if (lsr & UART_LSR_FE)
1412 up->port.icount.frame++; 1414 port->icount.frame++;
1413 if (lsr & UART_LSR_OE) 1415 if (lsr & UART_LSR_OE)
1414 up->port.icount.overrun++; 1416 port->icount.overrun++;
1415 1417
1416 /* 1418 /*
1417 * Mask off conditions which should be ignored. 1419 * Mask off conditions which should be ignored.
1418 */ 1420 */
1419 lsr &= up->port.read_status_mask; 1421 lsr &= port->read_status_mask;
1420 1422
1421 if (lsr & UART_LSR_BI) { 1423 if (lsr & UART_LSR_BI) {
1422 DEBUG_INTR("handling break...."); 1424 DEBUG_INTR("handling break....");
@@ -1426,34 +1428,35 @@ serial8250_rx_chars(struct uart_8250_port *up, unsigned char lsr)
1426 else if (lsr & UART_LSR_FE) 1428 else if (lsr & UART_LSR_FE)
1427 flag = TTY_FRAME; 1429 flag = TTY_FRAME;
1428 } 1430 }
1429 if (uart_handle_sysrq_char(&up->port, ch)) 1431 if (uart_handle_sysrq_char(port, ch))
1430 goto ignore_char; 1432 goto ignore_char;
1431 1433
1432 uart_insert_char(&up->port, lsr, UART_LSR_OE, ch, flag); 1434 uart_insert_char(port, lsr, UART_LSR_OE, ch, flag);
1433 1435
1434ignore_char: 1436ignore_char:
1435 lsr = serial_in(up, UART_LSR); 1437 lsr = serial_in(up, UART_LSR);
1436 } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0)); 1438 } while ((lsr & (UART_LSR_DR | UART_LSR_BI)) && (max_count-- > 0));
1437 spin_unlock(&up->port.lock); 1439 spin_unlock(&port->lock);
1438 tty_flip_buffer_push(tty); 1440 tty_flip_buffer_push(tty);
1439 spin_lock(&up->port.lock); 1441 spin_lock(&port->lock);
1440 return lsr; 1442 return lsr;
1441} 1443}
1442EXPORT_SYMBOL_GPL(serial8250_rx_chars); 1444EXPORT_SYMBOL_GPL(serial8250_rx_chars);
1443 1445
1444void serial8250_tx_chars(struct uart_8250_port *up) 1446void serial8250_tx_chars(struct uart_8250_port *up)
1445{ 1447{
1446 struct circ_buf *xmit = &up->port.state->xmit; 1448 struct uart_port *port = &up->port;
1449 struct circ_buf *xmit = &port->state->xmit;
1447 int count; 1450 int count;
1448 1451
1449 if (up->port.x_char) { 1452 if (port->x_char) {
1450 serial_out(up, UART_TX, up->port.x_char); 1453 serial_out(up, UART_TX, port->x_char);
1451 up->port.icount.tx++; 1454 port->icount.tx++;
1452 up->port.x_char = 0; 1455 port->x_char = 0;
1453 return; 1456 return;
1454 } 1457 }
1455 if (uart_tx_stopped(&up->port)) { 1458 if (uart_tx_stopped(port)) {
1456 serial8250_stop_tx(&up->port); 1459 serial8250_stop_tx(port);
1457 return; 1460 return;
1458 } 1461 }
1459 if (uart_circ_empty(xmit)) { 1462 if (uart_circ_empty(xmit)) {
@@ -1465,13 +1468,13 @@ void serial8250_tx_chars(struct uart_8250_port *up)
1465 do { 1468 do {
1466 serial_out(up, UART_TX, xmit->buf[xmit->tail]); 1469 serial_out(up, UART_TX, xmit->buf[xmit->tail]);
1467 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1); 1470 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
1468 up->port.icount.tx++; 1471 port->icount.tx++;
1469 if (uart_circ_empty(xmit)) 1472 if (uart_circ_empty(xmit))
1470 break; 1473 break;
1471 } while (--count > 0); 1474 } while (--count > 0);
1472 1475
1473 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS) 1476 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
1474 uart_write_wakeup(&up->port); 1477 uart_write_wakeup(port);
1475 1478
1476 DEBUG_INTR("THRE..."); 1479 DEBUG_INTR("THRE...");
1477 1480
@@ -1482,22 +1485,23 @@ EXPORT_SYMBOL_GPL(serial8250_tx_chars);
1482 1485
1483unsigned int serial8250_modem_status(struct uart_8250_port *up) 1486unsigned int serial8250_modem_status(struct uart_8250_port *up)
1484{ 1487{
1488 struct uart_port *port = &up->port;
1485 unsigned int status = serial_in(up, UART_MSR); 1489 unsigned int status = serial_in(up, UART_MSR);
1486 1490
1487 status |= up->msr_saved_flags; 1491 status |= up->msr_saved_flags;
1488 up->msr_saved_flags = 0; 1492 up->msr_saved_flags = 0;
1489 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI && 1493 if (status & UART_MSR_ANY_DELTA && up->ier & UART_IER_MSI &&
1490 up->port.state != NULL) { 1494 port->state != NULL) {
1491 if (status & UART_MSR_TERI) 1495 if (status & UART_MSR_TERI)
1492 up->port.icount.rng++; 1496 port->icount.rng++;
1493 if (status & UART_MSR_DDSR) 1497 if (status & UART_MSR_DDSR)
1494 up->port.icount.dsr++; 1498 port->icount.dsr++;
1495 if (status & UART_MSR_DDCD) 1499 if (status & UART_MSR_DDCD)
1496 uart_handle_dcd_change(&up->port, status & UART_MSR_DCD); 1500 uart_handle_dcd_change(port, status & UART_MSR_DCD);
1497 if (status & UART_MSR_DCTS) 1501 if (status & UART_MSR_DCTS)
1498 uart_handle_cts_change(&up->port, status & UART_MSR_CTS); 1502 uart_handle_cts_change(port, status & UART_MSR_CTS);
1499 1503
1500 wake_up_interruptible(&up->port.state->port.delta_msr_wait); 1504 wake_up_interruptible(&port->state->port.delta_msr_wait);
1501 } 1505 }
1502 1506
1503 return status; 1507 return status;
@@ -1517,7 +1521,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
1517 if (iir & UART_IIR_NO_INT) 1521 if (iir & UART_IIR_NO_INT)
1518 return 0; 1522 return 0;
1519 1523
1520 spin_lock_irqsave(&up->port.lock, flags); 1524 spin_lock_irqsave(&port->lock, flags);
1521 1525
1522 status = serial_in(up, UART_LSR); 1526 status = serial_in(up, UART_LSR);
1523 1527
@@ -1529,7 +1533,7 @@ int serial8250_handle_irq(struct uart_port *port, unsigned int iir)
1529 if (status & UART_LSR_THRE) 1533 if (status & UART_LSR_THRE)
1530 serial8250_tx_chars(up); 1534 serial8250_tx_chars(up);
1531 1535
1532 spin_unlock_irqrestore(&up->port.lock, flags); 1536 spin_unlock_irqrestore(&port->lock, flags);
1533 return 1; 1537 return 1;
1534} 1538}
1535EXPORT_SYMBOL_GPL(serial8250_handle_irq); 1539EXPORT_SYMBOL_GPL(serial8250_handle_irq);
@@ -1771,10 +1775,10 @@ static unsigned int serial8250_tx_empty(struct uart_port *port)
1771 unsigned long flags; 1775 unsigned long flags;
1772 unsigned int lsr; 1776 unsigned int lsr;
1773 1777
1774 spin_lock_irqsave(&up->port.lock, flags); 1778 spin_lock_irqsave(&port->lock, flags);
1775 lsr = serial_in(up, UART_LSR); 1779 lsr = serial_in(up, UART_LSR);
1776 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS; 1780 up->lsr_saved_flags |= lsr & LSR_SAVE_FLAGS;
1777 spin_unlock_irqrestore(&up->port.lock, flags); 1781 spin_unlock_irqrestore(&port->lock, flags);
1778 1782
1779 return (lsr & BOTH_EMPTY) == BOTH_EMPTY ? TIOCSER_TEMT : 0; 1783 return (lsr & BOTH_EMPTY) == BOTH_EMPTY ? TIOCSER_TEMT : 0;
1780} 1784}
@@ -1828,13 +1832,13 @@ static void serial8250_break_ctl(struct uart_port *port, int break_state)
1828 container_of(port, struct uart_8250_port, port); 1832 container_of(port, struct uart_8250_port, port);
1829 unsigned long flags; 1833 unsigned long flags;
1830 1834
1831 spin_lock_irqsave(&up->port.lock, flags); 1835 spin_lock_irqsave(&port->lock, flags);
1832 if (break_state == -1) 1836 if (break_state == -1)
1833 up->lcr |= UART_LCR_SBC; 1837 up->lcr |= UART_LCR_SBC;
1834 else 1838 else
1835 up->lcr &= ~UART_LCR_SBC; 1839 up->lcr &= ~UART_LCR_SBC;
1836 serial_out(up, UART_LCR, up->lcr); 1840 serial_out(up, UART_LCR, up->lcr);
1837 spin_unlock_irqrestore(&up->port.lock, flags); 1841 spin_unlock_irqrestore(&port->lock, flags);
1838} 1842}
1839 1843
1840/* 1844/*
@@ -1935,15 +1939,15 @@ static int serial8250_startup(struct uart_port *port)
1935 unsigned char lsr, iir; 1939 unsigned char lsr, iir;
1936 int retval; 1940 int retval;
1937 1941
1938 up->port.fifosize = uart_config[up->port.type].fifo_size; 1942 port->fifosize = uart_config[up->port.type].fifo_size;
1939 up->tx_loadsz = uart_config[up->port.type].tx_loadsz; 1943 up->tx_loadsz = uart_config[up->port.type].tx_loadsz;
1940 up->capabilities = uart_config[up->port.type].flags; 1944 up->capabilities = uart_config[up->port.type].flags;
1941 up->mcr = 0; 1945 up->mcr = 0;
1942 1946
1943 if (up->port.iotype != up->cur_iotype) 1947 if (port->iotype != up->cur_iotype)
1944 set_io_from_upio(port); 1948 set_io_from_upio(port);
1945 1949
1946 if (up->port.type == PORT_16C950) { 1950 if (port->type == PORT_16C950) {
1947 /* Wake up and initialize UART */ 1951 /* Wake up and initialize UART */
1948 up->acr = 0; 1952 up->acr = 0;
1949 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); 1953 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
@@ -1983,17 +1987,17 @@ static int serial8250_startup(struct uart_port *port)
1983 * if it is, then bail out, because there's likely no UART 1987 * if it is, then bail out, because there's likely no UART
1984 * here. 1988 * here.
1985 */ 1989 */
1986 if (!(up->port.flags & UPF_BUGGY_UART) && 1990 if (!(port->flags & UPF_BUGGY_UART) &&
1987 (serial_in(up, UART_LSR) == 0xff)) { 1991 (serial_in(up, UART_LSR) == 0xff)) {
1988 printk_ratelimited(KERN_INFO "ttyS%d: LSR safety check engaged!\n", 1992 printk_ratelimited(KERN_INFO "ttyS%d: LSR safety check engaged!\n",
1989 serial_index(&up->port)); 1993 serial_index(port));
1990 return -ENODEV; 1994 return -ENODEV;
1991 } 1995 }
1992 1996
1993 /* 1997 /*
1994 * For a XR16C850, we need to set the trigger levels 1998 * For a XR16C850, we need to set the trigger levels
1995 */ 1999 */
1996 if (up->port.type == PORT_16850) { 2000 if (port->type == PORT_16850) {
1997 unsigned char fctr; 2001 unsigned char fctr;
1998 2002
1999 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); 2003 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
@@ -2007,7 +2011,7 @@ static int serial8250_startup(struct uart_port *port)
2007 serial_out(up, UART_LCR, 0); 2011 serial_out(up, UART_LCR, 0);
2008 } 2012 }
2009 2013
2010 if (up->port.irq) { 2014 if (port->irq) {
2011 unsigned char iir1; 2015 unsigned char iir1;
2012 /* 2016 /*
2013 * Test for UARTs that do not reassert THRE when the 2017 * Test for UARTs that do not reassert THRE when the
@@ -2017,9 +2021,9 @@ static int serial8250_startup(struct uart_port *port)
2017 * the interrupt is enabled. Delays are necessary to 2021 * the interrupt is enabled. Delays are necessary to
2018 * allow register changes to become visible. 2022 * allow register changes to become visible.
2019 */ 2023 */
2020 spin_lock_irqsave(&up->port.lock, flags); 2024 spin_lock_irqsave(&port->lock, flags);
2021 if (up->port.irqflags & IRQF_SHARED) 2025 if (up->port.irqflags & IRQF_SHARED)
2022 disable_irq_nosync(up->port.irq); 2026 disable_irq_nosync(port->irq);
2023 2027
2024 wait_for_xmitr(up, UART_LSR_THRE); 2028 wait_for_xmitr(up, UART_LSR_THRE);
2025 serial_out_sync(up, UART_IER, UART_IER_THRI); 2029 serial_out_sync(up, UART_IER, UART_IER_THRI);
@@ -2031,9 +2035,9 @@ static int serial8250_startup(struct uart_port *port)
2031 iir = serial_in(up, UART_IIR); 2035 iir = serial_in(up, UART_IIR);
2032 serial_out(up, UART_IER, 0); 2036 serial_out(up, UART_IER, 0);
2033 2037
2034 if (up->port.irqflags & IRQF_SHARED) 2038 if (port->irqflags & IRQF_SHARED)
2035 enable_irq(up->port.irq); 2039 enable_irq(port->irq);
2036 spin_unlock_irqrestore(&up->port.lock, flags); 2040 spin_unlock_irqrestore(&port->lock, flags);
2037 2041
2038 /* 2042 /*
2039 * If the interrupt is not reasserted, setup a timer to 2043 * If the interrupt is not reasserted, setup a timer to
@@ -2062,7 +2066,7 @@ static int serial8250_startup(struct uart_port *port)
2062 * hardware interrupt, we use a timer-based system. The original 2066 * hardware interrupt, we use a timer-based system. The original
2063 * driver used to do this with IRQ0. 2067 * driver used to do this with IRQ0.
2064 */ 2068 */
2065 if (!up->port.irq) { 2069 if (!port->irq) {
2066 up->timer.data = (unsigned long)up; 2070 up->timer.data = (unsigned long)up;
2067 mod_timer(&up->timer, jiffies + uart_poll_timeout(port)); 2071 mod_timer(&up->timer, jiffies + uart_poll_timeout(port));
2068 } else { 2072 } else {
@@ -2076,7 +2080,7 @@ static int serial8250_startup(struct uart_port *port)
2076 */ 2080 */
2077 serial_out(up, UART_LCR, UART_LCR_WLEN8); 2081 serial_out(up, UART_LCR, UART_LCR_WLEN8);
2078 2082
2079 spin_lock_irqsave(&up->port.lock, flags); 2083 spin_lock_irqsave(&port->lock, flags);
2080 if (up->port.flags & UPF_FOURPORT) { 2084 if (up->port.flags & UPF_FOURPORT) {
2081 if (!up->port.irq) 2085 if (!up->port.irq)
2082 up->port.mctrl |= TIOCM_OUT1; 2086 up->port.mctrl |= TIOCM_OUT1;
@@ -2084,10 +2088,10 @@ static int serial8250_startup(struct uart_port *port)
2084 /* 2088 /*
2085 * Most PC uarts need OUT2 raised to enable interrupts. 2089 * Most PC uarts need OUT2 raised to enable interrupts.
2086 */ 2090 */
2087 if (up->port.irq) 2091 if (port->irq)
2088 up->port.mctrl |= TIOCM_OUT2; 2092 up->port.mctrl |= TIOCM_OUT2;
2089 2093
2090 serial8250_set_mctrl(&up->port, up->port.mctrl); 2094 serial8250_set_mctrl(port, port->mctrl);
2091 2095
2092 /* Serial over Lan (SoL) hack: 2096 /* Serial over Lan (SoL) hack:
2093 Intel 8257x Gigabit ethernet chips have a 2097 Intel 8257x Gigabit ethernet chips have a
@@ -2123,7 +2127,7 @@ static int serial8250_startup(struct uart_port *port)
2123 } 2127 }
2124 2128
2125dont_test_tx_en: 2129dont_test_tx_en:
2126 spin_unlock_irqrestore(&up->port.lock, flags); 2130 spin_unlock_irqrestore(&port->lock, flags);
2127 2131
2128 /* 2132 /*
2129 * Clear the interrupt registers again for luck, and clear the 2133 * Clear the interrupt registers again for luck, and clear the
@@ -2145,12 +2149,12 @@ dont_test_tx_en:
2145 up->ier = UART_IER_RLSI | UART_IER_RDI; 2149 up->ier = UART_IER_RLSI | UART_IER_RDI;
2146 serial_out(up, UART_IER, up->ier); 2150 serial_out(up, UART_IER, up->ier);
2147 2151
2148 if (up->port.flags & UPF_FOURPORT) { 2152 if (port->flags & UPF_FOURPORT) {
2149 unsigned int icp; 2153 unsigned int icp;
2150 /* 2154 /*
2151 * Enable interrupts on the AST Fourport board 2155 * Enable interrupts on the AST Fourport board
2152 */ 2156 */
2153 icp = (up->port.iobase & 0xfe0) | 0x01f; 2157 icp = (port->iobase & 0xfe0) | 0x01f;
2154 outb_p(0x80, icp); 2158 outb_p(0x80, icp);
2155 inb_p(icp); 2159 inb_p(icp);
2156 } 2160 }
@@ -2170,16 +2174,16 @@ static void serial8250_shutdown(struct uart_port *port)
2170 up->ier = 0; 2174 up->ier = 0;
2171 serial_out(up, UART_IER, 0); 2175 serial_out(up, UART_IER, 0);
2172 2176
2173 spin_lock_irqsave(&up->port.lock, flags); 2177 spin_lock_irqsave(&port->lock, flags);
2174 if (up->port.flags & UPF_FOURPORT) { 2178 if (port->flags & UPF_FOURPORT) {
2175 /* reset interrupts on the AST Fourport board */ 2179 /* reset interrupts on the AST Fourport board */
2176 inb((up->port.iobase & 0xfe0) | 0x1f); 2180 inb((port->iobase & 0xfe0) | 0x1f);
2177 up->port.mctrl |= TIOCM_OUT1; 2181 port->mctrl |= TIOCM_OUT1;
2178 } else 2182 } else
2179 up->port.mctrl &= ~TIOCM_OUT2; 2183 port->mctrl &= ~TIOCM_OUT2;
2180 2184
2181 serial8250_set_mctrl(&up->port, up->port.mctrl); 2185 serial8250_set_mctrl(port, port->mctrl);
2182 spin_unlock_irqrestore(&up->port.lock, flags); 2186 spin_unlock_irqrestore(&port->lock, flags);
2183 2187
2184 /* 2188 /*
2185 * Disable break condition and FIFOs 2189 * Disable break condition and FIFOs
@@ -2202,7 +2206,7 @@ static void serial8250_shutdown(struct uart_port *port)
2202 2206
2203 del_timer_sync(&up->timer); 2207 del_timer_sync(&up->timer);
2204 up->timer.function = serial8250_timeout; 2208 up->timer.function = serial8250_timeout;
2205 if (up->port.irq) 2209 if (port->irq)
2206 serial_unlink_irq_chain(up); 2210 serial_unlink_irq_chain(up);
2207} 2211}
2208 2212
@@ -2277,11 +2281,11 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2277 if (up->bugs & UART_BUG_QUOT && (quot & 0xff) == 0) 2281 if (up->bugs & UART_BUG_QUOT && (quot & 0xff) == 0)
2278 quot++; 2282 quot++;
2279 2283
2280 if (up->capabilities & UART_CAP_FIFO && up->port.fifosize > 1) { 2284 if (up->capabilities & UART_CAP_FIFO && port->fifosize > 1) {
2281 if (baud < 2400) 2285 if (baud < 2400)
2282 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1; 2286 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
2283 else 2287 else
2284 fcr = uart_config[up->port.type].fcr; 2288 fcr = uart_config[port->type].fcr;
2285 } 2289 }
2286 2290
2287 /* 2291 /*
@@ -2292,7 +2296,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2292 * have sufficient FIFO entries for the latency of the remote 2296 * have sufficient FIFO entries for the latency of the remote
2293 * UART to respond. IOW, at least 32 bytes of FIFO. 2297 * UART to respond. IOW, at least 32 bytes of FIFO.
2294 */ 2298 */
2295 if (up->capabilities & UART_CAP_AFE && up->port.fifosize >= 32) { 2299 if (up->capabilities & UART_CAP_AFE && port->fifosize >= 32) {
2296 up->mcr &= ~UART_MCR_AFE; 2300 up->mcr &= ~UART_MCR_AFE;
2297 if (termios->c_cflag & CRTSCTS) 2301 if (termios->c_cflag & CRTSCTS)
2298 up->mcr |= UART_MCR_AFE; 2302 up->mcr |= UART_MCR_AFE;
@@ -2302,40 +2306,40 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2302 * Ok, we're now changing the port state. Do it with 2306 * Ok, we're now changing the port state. Do it with
2303 * interrupts disabled. 2307 * interrupts disabled.
2304 */ 2308 */
2305 spin_lock_irqsave(&up->port.lock, flags); 2309 spin_lock_irqsave(&port->lock, flags);
2306 2310
2307 /* 2311 /*
2308 * Update the per-port timeout. 2312 * Update the per-port timeout.
2309 */ 2313 */
2310 uart_update_timeout(port, termios->c_cflag, baud); 2314 uart_update_timeout(port, termios->c_cflag, baud);
2311 2315
2312 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR; 2316 port->read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
2313 if (termios->c_iflag & INPCK) 2317 if (termios->c_iflag & INPCK)
2314 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE; 2318 port->read_status_mask |= UART_LSR_FE | UART_LSR_PE;
2315 if (termios->c_iflag & (BRKINT | PARMRK)) 2319 if (termios->c_iflag & (BRKINT | PARMRK))
2316 up->port.read_status_mask |= UART_LSR_BI; 2320 port->read_status_mask |= UART_LSR_BI;
2317 2321
2318 /* 2322 /*
2319 * Characteres to ignore 2323 * Characteres to ignore
2320 */ 2324 */
2321 up->port.ignore_status_mask = 0; 2325 port->ignore_status_mask = 0;
2322 if (termios->c_iflag & IGNPAR) 2326 if (termios->c_iflag & IGNPAR)
2323 up->port.ignore_status_mask |= UART_LSR_PE | UART_LSR_FE; 2327 port->ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
2324 if (termios->c_iflag & IGNBRK) { 2328 if (termios->c_iflag & IGNBRK) {
2325 up->port.ignore_status_mask |= UART_LSR_BI; 2329 port->ignore_status_mask |= UART_LSR_BI;
2326 /* 2330 /*
2327 * If we're ignoring parity and break indicators, 2331 * If we're ignoring parity and break indicators,
2328 * ignore overruns too (for real raw support). 2332 * ignore overruns too (for real raw support).
2329 */ 2333 */
2330 if (termios->c_iflag & IGNPAR) 2334 if (termios->c_iflag & IGNPAR)
2331 up->port.ignore_status_mask |= UART_LSR_OE; 2335 port->ignore_status_mask |= UART_LSR_OE;
2332 } 2336 }
2333 2337
2334 /* 2338 /*
2335 * ignore all characters if CREAD is not set 2339 * ignore all characters if CREAD is not set
2336 */ 2340 */
2337 if ((termios->c_cflag & CREAD) == 0) 2341 if ((termios->c_cflag & CREAD) == 0)
2338 up->port.ignore_status_mask |= UART_LSR_DR; 2342 port->ignore_status_mask |= UART_LSR_DR;
2339 2343
2340 /* 2344 /*
2341 * CTS flow control flag and modem status interrupts 2345 * CTS flow control flag and modem status interrupts
@@ -2362,7 +2366,7 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2362 efr |= UART_EFR_CTS; 2366 efr |= UART_EFR_CTS;
2363 2367
2364 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B); 2368 serial_out(up, UART_LCR, UART_LCR_CONF_MODE_B);
2365 if (up->port.flags & UPF_EXAR_EFR) 2369 if (port->flags & UPF_EXAR_EFR)
2366 serial_out(up, UART_XR_EFR, efr); 2370 serial_out(up, UART_XR_EFR, efr);
2367 else 2371 else
2368 serial_out(up, UART_EFR, efr); 2372 serial_out(up, UART_EFR, efr);
@@ -2392,20 +2396,20 @@ serial8250_do_set_termios(struct uart_port *port, struct ktermios *termios,
2392 * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR 2396 * LCR DLAB must be set to enable 64-byte FIFO mode. If the FCR
2393 * is written without DLAB set, this mode will be disabled. 2397 * is written without DLAB set, this mode will be disabled.
2394 */ 2398 */
2395 if (up->port.type == PORT_16750) 2399 if (port->type == PORT_16750)
2396 serial_out(up, UART_FCR, fcr); 2400 serial_out(up, UART_FCR, fcr);
2397 2401
2398 serial_out(up, UART_LCR, cval); /* reset DLAB */ 2402 serial_out(up, UART_LCR, cval); /* reset DLAB */
2399 up->lcr = cval; /* Save LCR */ 2403 up->lcr = cval; /* Save LCR */
2400 if (up->port.type != PORT_16750) { 2404 if (port->type != PORT_16750) {
2401 if (fcr & UART_FCR_ENABLE_FIFO) { 2405 if (fcr & UART_FCR_ENABLE_FIFO) {
2402 /* emulated UARTs (Lucent Venus 167x) need two steps */ 2406 /* emulated UARTs (Lucent Venus 167x) need two steps */
2403 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO); 2407 serial_out(up, UART_FCR, UART_FCR_ENABLE_FIFO);
2404 } 2408 }
2405 serial_out(up, UART_FCR, fcr); /* set fcr */ 2409 serial_out(up, UART_FCR, fcr); /* set fcr */
2406 } 2410 }
2407 serial8250_set_mctrl(&up->port, up->port.mctrl); 2411 serial8250_set_mctrl(port, port->mctrl);
2408 spin_unlock_irqrestore(&up->port.lock, flags); 2412 spin_unlock_irqrestore(&port->lock, flags);
2409 /* Don't rewrite B0 */ 2413 /* Don't rewrite B0 */
2410 if (tty_termios_baud_rate(termios)) 2414 if (tty_termios_baud_rate(termios))
2411 tty_termios_encode_baud_rate(termios, baud, baud); 2415 tty_termios_encode_baud_rate(termios, baud, baud);
@@ -2470,26 +2474,26 @@ static unsigned int serial8250_port_size(struct uart_8250_port *pt)
2470static int serial8250_request_std_resource(struct uart_8250_port *up) 2474static int serial8250_request_std_resource(struct uart_8250_port *up)
2471{ 2475{
2472 unsigned int size = serial8250_port_size(up); 2476 unsigned int size = serial8250_port_size(up);
2477 struct uart_port *port = &up->port;
2473 int ret = 0; 2478 int ret = 0;
2474 2479
2475 switch (up->port.iotype) { 2480 switch (port->iotype) {
2476 case UPIO_AU: 2481 case UPIO_AU:
2477 case UPIO_TSI: 2482 case UPIO_TSI:
2478 case UPIO_MEM32: 2483 case UPIO_MEM32:
2479 case UPIO_MEM: 2484 case UPIO_MEM:
2480 if (!up->port.mapbase) 2485 if (!port->mapbase)
2481 break; 2486 break;
2482 2487
2483 if (!request_mem_region(up->port.mapbase, size, "serial")) { 2488 if (!request_mem_region(port->mapbase, size, "serial")) {
2484 ret = -EBUSY; 2489 ret = -EBUSY;
2485 break; 2490 break;
2486 } 2491 }
2487 2492
2488 if (up->port.flags & UPF_IOREMAP) { 2493 if (port->flags & UPF_IOREMAP) {
2489 up->port.membase = ioremap_nocache(up->port.mapbase, 2494 port->membase = ioremap_nocache(port->mapbase, size);
2490 size); 2495 if (!port->membase) {
2491 if (!up->port.membase) { 2496 release_mem_region(port->mapbase, size);
2492 release_mem_region(up->port.mapbase, size);
2493 ret = -ENOMEM; 2497 ret = -ENOMEM;
2494 } 2498 }
2495 } 2499 }
@@ -2497,7 +2501,7 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
2497 2501
2498 case UPIO_HUB6: 2502 case UPIO_HUB6:
2499 case UPIO_PORT: 2503 case UPIO_PORT:
2500 if (!request_region(up->port.iobase, size, "serial")) 2504 if (!request_region(port->iobase, size, "serial"))
2501 ret = -EBUSY; 2505 ret = -EBUSY;
2502 break; 2506 break;
2503 } 2507 }
@@ -2507,26 +2511,27 @@ static int serial8250_request_std_resource(struct uart_8250_port *up)
2507static void serial8250_release_std_resource(struct uart_8250_port *up) 2511static void serial8250_release_std_resource(struct uart_8250_port *up)
2508{ 2512{
2509 unsigned int size = serial8250_port_size(up); 2513 unsigned int size = serial8250_port_size(up);
2514 struct uart_port *port = &up->port;
2510 2515
2511 switch (up->port.iotype) { 2516 switch (port->iotype) {
2512 case UPIO_AU: 2517 case UPIO_AU:
2513 case UPIO_TSI: 2518 case UPIO_TSI:
2514 case UPIO_MEM32: 2519 case UPIO_MEM32:
2515 case UPIO_MEM: 2520 case UPIO_MEM:
2516 if (!up->port.mapbase) 2521 if (!port->mapbase)
2517 break; 2522 break;
2518 2523
2519 if (up->port.flags & UPF_IOREMAP) { 2524 if (port->flags & UPF_IOREMAP) {
2520 iounmap(up->port.membase); 2525 iounmap(port->membase);
2521 up->port.membase = NULL; 2526 port->membase = NULL;
2522 } 2527 }
2523 2528
2524 release_mem_region(up->port.mapbase, size); 2529 release_mem_region(port->mapbase, size);
2525 break; 2530 break;
2526 2531
2527 case UPIO_HUB6: 2532 case UPIO_HUB6:
2528 case UPIO_PORT: 2533 case UPIO_PORT:
2529 release_region(up->port.iobase, size); 2534 release_region(port->iobase, size);
2530 break; 2535 break;
2531 } 2536 }
2532} 2537}
@@ -2535,12 +2540,13 @@ static int serial8250_request_rsa_resource(struct uart_8250_port *up)
2535{ 2540{
2536 unsigned long start = UART_RSA_BASE << up->port.regshift; 2541 unsigned long start = UART_RSA_BASE << up->port.regshift;
2537 unsigned int size = 8 << up->port.regshift; 2542 unsigned int size = 8 << up->port.regshift;
2543 struct uart_port *port = &up->port;
2538 int ret = -EINVAL; 2544 int ret = -EINVAL;
2539 2545
2540 switch (up->port.iotype) { 2546 switch (port->iotype) {
2541 case UPIO_HUB6: 2547 case UPIO_HUB6:
2542 case UPIO_PORT: 2548 case UPIO_PORT:
2543 start += up->port.iobase; 2549 start += port->iobase;
2544 if (request_region(start, size, "serial-rsa")) 2550 if (request_region(start, size, "serial-rsa"))
2545 ret = 0; 2551 ret = 0;
2546 else 2552 else
@@ -2555,11 +2561,12 @@ static void serial8250_release_rsa_resource(struct uart_8250_port *up)
2555{ 2561{
2556 unsigned long offset = UART_RSA_BASE << up->port.regshift; 2562 unsigned long offset = UART_RSA_BASE << up->port.regshift;
2557 unsigned int size = 8 << up->port.regshift; 2563 unsigned int size = 8 << up->port.regshift;
2564 struct uart_port *port = &up->port;
2558 2565
2559 switch (up->port.iotype) { 2566 switch (port->iotype) {
2560 case UPIO_HUB6: 2567 case UPIO_HUB6:
2561 case UPIO_PORT: 2568 case UPIO_PORT:
2562 release_region(up->port.iobase + offset, size); 2569 release_region(port->iobase + offset, size);
2563 break; 2570 break;
2564 } 2571 }
2565} 2572}
@@ -2570,7 +2577,7 @@ static void serial8250_release_port(struct uart_port *port)
2570 container_of(port, struct uart_8250_port, port); 2577 container_of(port, struct uart_8250_port, port);
2571 2578
2572 serial8250_release_std_resource(up); 2579 serial8250_release_std_resource(up);
2573 if (up->port.type == PORT_RSA) 2580 if (port->type == PORT_RSA)
2574 serial8250_release_rsa_resource(up); 2581 serial8250_release_rsa_resource(up);
2575} 2582}
2576 2583
@@ -2581,7 +2588,7 @@ static int serial8250_request_port(struct uart_port *port)
2581 int ret = 0; 2588 int ret = 0;
2582 2589
2583 ret = serial8250_request_std_resource(up); 2590 ret = serial8250_request_std_resource(up);
2584 if (ret == 0 && up->port.type == PORT_RSA) { 2591 if (ret == 0 && port->type == PORT_RSA) {
2585 ret = serial8250_request_rsa_resource(up); 2592 ret = serial8250_request_rsa_resource(up);
2586 if (ret < 0) 2593 if (ret < 0)
2587 serial8250_release_std_resource(up); 2594 serial8250_release_std_resource(up);
@@ -2609,22 +2616,22 @@ static void serial8250_config_port(struct uart_port *port, int flags)
2609 if (ret < 0) 2616 if (ret < 0)
2610 probeflags &= ~PROBE_RSA; 2617 probeflags &= ~PROBE_RSA;
2611 2618
2612 if (up->port.iotype != up->cur_iotype) 2619 if (port->iotype != up->cur_iotype)
2613 set_io_from_upio(port); 2620 set_io_from_upio(port);
2614 2621
2615 if (flags & UART_CONFIG_TYPE) 2622 if (flags & UART_CONFIG_TYPE)
2616 autoconfig(up, probeflags); 2623 autoconfig(up, probeflags);
2617 2624
2618 /* if access method is AU, it is a 16550 with a quirk */ 2625 /* if access method is AU, it is a 16550 with a quirk */
2619 if (up->port.type == PORT_16550A && up->port.iotype == UPIO_AU) 2626 if (port->type == PORT_16550A && port->iotype == UPIO_AU)
2620 up->bugs |= UART_BUG_NOMSR; 2627 up->bugs |= UART_BUG_NOMSR;
2621 2628
2622 if (up->port.type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ) 2629 if (port->type != PORT_UNKNOWN && flags & UART_CONFIG_IRQ)
2623 autoconfig_irq(up); 2630 autoconfig_irq(up);
2624 2631
2625 if (up->port.type != PORT_RSA && probeflags & PROBE_RSA) 2632 if (port->type != PORT_RSA && probeflags & PROBE_RSA)
2626 serial8250_release_rsa_resource(up); 2633 serial8250_release_rsa_resource(up);
2627 if (up->port.type == PORT_UNKNOWN) 2634 if (port->type == PORT_UNKNOWN)
2628 serial8250_release_std_resource(up); 2635 serial8250_release_std_resource(up);
2629} 2636}
2630 2637
@@ -2698,9 +2705,10 @@ static void __init serial8250_isa_init_ports(void)
2698 2705
2699 for (i = 0; i < nr_uarts; i++) { 2706 for (i = 0; i < nr_uarts; i++) {
2700 struct uart_8250_port *up = &serial8250_ports[i]; 2707 struct uart_8250_port *up = &serial8250_ports[i];
2708 struct uart_port *port = &up->port;
2701 2709
2702 up->port.line = i; 2710 port->line = i;
2703 spin_lock_init(&up->port.lock); 2711 spin_lock_init(&port->lock);
2704 2712
2705 init_timer(&up->timer); 2713 init_timer(&up->timer);
2706 up->timer.function = serial8250_timeout; 2714 up->timer.function = serial8250_timeout;
@@ -2711,7 +2719,7 @@ static void __init serial8250_isa_init_ports(void)
2711 up->mcr_mask = ~ALPHA_KLUDGE_MCR; 2719 up->mcr_mask = ~ALPHA_KLUDGE_MCR;
2712 up->mcr_force = ALPHA_KLUDGE_MCR; 2720 up->mcr_force = ALPHA_KLUDGE_MCR;
2713 2721
2714 up->port.ops = &serial8250_pops; 2722 port->ops = &serial8250_pops;
2715 } 2723 }
2716 2724
2717 if (share_irqs) 2725 if (share_irqs)
@@ -2720,17 +2728,19 @@ static void __init serial8250_isa_init_ports(void)
2720 for (i = 0, up = serial8250_ports; 2728 for (i = 0, up = serial8250_ports;
2721 i < ARRAY_SIZE(old_serial_port) && i < nr_uarts; 2729 i < ARRAY_SIZE(old_serial_port) && i < nr_uarts;
2722 i++, up++) { 2730 i++, up++) {
2723 up->port.iobase = old_serial_port[i].port; 2731 struct uart_port *port = &up->port;
2724 up->port.irq = irq_canonicalize(old_serial_port[i].irq); 2732
2725 up->port.irqflags = old_serial_port[i].irqflags; 2733 port->iobase = old_serial_port[i].port;
2726 up->port.uartclk = old_serial_port[i].baud_base * 16; 2734 port->irq = irq_canonicalize(old_serial_port[i].irq);
2727 up->port.flags = old_serial_port[i].flags; 2735 port->irqflags = old_serial_port[i].irqflags;
2728 up->port.hub6 = old_serial_port[i].hub6; 2736 port->uartclk = old_serial_port[i].baud_base * 16;
2729 up->port.membase = old_serial_port[i].iomem_base; 2737 port->flags = old_serial_port[i].flags;
2730 up->port.iotype = old_serial_port[i].io_type; 2738 port->hub6 = old_serial_port[i].hub6;
2731 up->port.regshift = old_serial_port[i].iomem_reg_shift; 2739 port->membase = old_serial_port[i].iomem_base;
2732 set_io_from_upio(&up->port); 2740 port->iotype = old_serial_port[i].io_type;
2733 up->port.irqflags |= irqflag; 2741 port->regshift = old_serial_port[i].iomem_reg_shift;
2742 set_io_from_upio(port);
2743 port->irqflags |= irqflag;
2734 if (serial8250_isa_config != NULL) 2744 if (serial8250_isa_config != NULL)
2735 serial8250_isa_config(i, &up->port, &up->capabilities); 2745 serial8250_isa_config(i, &up->port, &up->capabilities);
2736 2746
@@ -2791,6 +2801,7 @@ static void
2791serial8250_console_write(struct console *co, const char *s, unsigned int count) 2801serial8250_console_write(struct console *co, const char *s, unsigned int count)
2792{ 2802{
2793 struct uart_8250_port *up = &serial8250_ports[co->index]; 2803 struct uart_8250_port *up = &serial8250_ports[co->index];
2804 struct uart_port *port = &up->port;
2794 unsigned long flags; 2805 unsigned long flags;
2795 unsigned int ier; 2806 unsigned int ier;
2796 int locked = 1; 2807 int locked = 1;
@@ -2798,13 +2809,13 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2798 touch_nmi_watchdog(); 2809 touch_nmi_watchdog();
2799 2810
2800 local_irq_save(flags); 2811 local_irq_save(flags);
2801 if (up->port.sysrq) { 2812 if (port->sysrq) {
2802 /* serial8250_handle_irq() already took the lock */ 2813 /* serial8250_handle_irq() already took the lock */
2803 locked = 0; 2814 locked = 0;
2804 } else if (oops_in_progress) { 2815 } else if (oops_in_progress) {
2805 locked = spin_trylock(&up->port.lock); 2816 locked = spin_trylock(&port->lock);
2806 } else 2817 } else
2807 spin_lock(&up->port.lock); 2818 spin_lock(&port->lock);
2808 2819
2809 /* 2820 /*
2810 * First save the IER then disable the interrupts 2821 * 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 else 2827 else
2817 serial_out(up, UART_IER, 0); 2828 serial_out(up, UART_IER, 0);
2818 2829
2819 uart_console_write(&up->port, s, count, serial8250_console_putchar); 2830 uart_console_write(port, s, count, serial8250_console_putchar);
2820 2831
2821 /* 2832 /*
2822 * Finally, wait for transmitter to become empty 2833 * Finally, wait for transmitter to become empty
@@ -2836,7 +2847,7 @@ serial8250_console_write(struct console *co, const char *s, unsigned int count)
2836 serial8250_modem_status(up); 2847 serial8250_modem_status(up);
2837 2848
2838 if (locked) 2849 if (locked)
2839 spin_unlock(&up->port.lock); 2850 spin_unlock(&port->lock);
2840 local_irq_restore(flags); 2851 local_irq_restore(flags);
2841} 2852}
2842 2853
@@ -2981,6 +2992,7 @@ void serial8250_suspend_port(int line)
2981void serial8250_resume_port(int line) 2992void serial8250_resume_port(int line)
2982{ 2993{
2983 struct uart_8250_port *up = &serial8250_ports[line]; 2994 struct uart_8250_port *up = &serial8250_ports[line];
2995 struct uart_port *port = &up->port;
2984 2996
2985 if (up->capabilities & UART_NATSEMI) { 2997 if (up->capabilities & UART_NATSEMI) {
2986 /* Ensure it's still in high speed mode */ 2998 /* Ensure it's still in high speed mode */
@@ -2989,9 +3001,9 @@ void serial8250_resume_port(int line)
2989 ns16550a_goto_highspeed(up); 3001 ns16550a_goto_highspeed(up);
2990 3002
2991 serial_out(up, UART_LCR, 0); 3003 serial_out(up, UART_LCR, 0);
2992 up->port.uartclk = 921600*16; 3004 port->uartclk = 921600*16;
2993 } 3005 }
2994 uart_resume_port(&serial8250_reg, &up->port); 3006 uart_resume_port(&serial8250_reg, port);
2995} 3007}
2996 3008
2997/* 3009/*