aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2012-03-05 08:52:43 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-03-08 15:50:01 -0500
commit7188dc202a9bdc3c6552232e036be471b0c50406 (patch)
tree8f7fe513b5417c34fa09b4b10444d9a8e9eb3d40 /drivers/tty
parent6e9ebcfa20b15f0ccdd4b5395a3c63f79c21fa57 (diff)
TTY: amiserial, define local tty_port pointer
And use it to make the code more readable. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Cc: Geert Uytterhoeven <geert@linux-m68k.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/amiserial.c81
1 files changed, 42 insertions, 39 deletions
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c
index 7d798262d0c..a9f5da64eef 100644
--- a/drivers/tty/amiserial.c
+++ b/drivers/tty/amiserial.c
@@ -361,6 +361,7 @@ static void transmit_chars(struct serial_state *info)
361 361
362static void check_modem_status(struct serial_state *info) 362static void check_modem_status(struct serial_state *info)
363{ 363{
364 struct tty_port *port = &info->tport;
364 unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR); 365 unsigned char status = ciab.pra & (SER_DCD | SER_CTS | SER_DSR);
365 unsigned char dstatus; 366 unsigned char dstatus;
366 struct async_icount *icount; 367 struct async_icount *icount;
@@ -377,45 +378,45 @@ static void check_modem_status(struct serial_state *info)
377 if (dstatus & SER_DCD) { 378 if (dstatus & SER_DCD) {
378 icount->dcd++; 379 icount->dcd++;
379#ifdef CONFIG_HARD_PPS 380#ifdef CONFIG_HARD_PPS
380 if ((info->tport.flags & ASYNC_HARDPPS_CD) && 381 if ((port->flags & ASYNC_HARDPPS_CD) &&
381 !(status & SER_DCD)) 382 !(status & SER_DCD))
382 hardpps(); 383 hardpps();
383#endif 384#endif
384 } 385 }
385 if (dstatus & SER_CTS) 386 if (dstatus & SER_CTS)
386 icount->cts++; 387 icount->cts++;
387 wake_up_interruptible(&info->tport.delta_msr_wait); 388 wake_up_interruptible(&port->delta_msr_wait);
388 } 389 }
389 390
390 if ((info->tport.flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) { 391 if ((port->flags & ASYNC_CHECK_CD) && (dstatus & SER_DCD)) {
391#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR)) 392#if (defined(SERIAL_DEBUG_OPEN) || defined(SERIAL_DEBUG_INTR))
392 printk("ttyS%d CD now %s...", info->line, 393 printk("ttyS%d CD now %s...", info->line,
393 (!(status & SER_DCD)) ? "on" : "off"); 394 (!(status & SER_DCD)) ? "on" : "off");
394#endif 395#endif
395 if (!(status & SER_DCD)) 396 if (!(status & SER_DCD))
396 wake_up_interruptible(&info->tport.open_wait); 397 wake_up_interruptible(&port->open_wait);
397 else { 398 else {
398#ifdef SERIAL_DEBUG_OPEN 399#ifdef SERIAL_DEBUG_OPEN
399 printk("doing serial hangup..."); 400 printk("doing serial hangup...");
400#endif 401#endif
401 if (info->tport.tty) 402 if (port->tty)
402 tty_hangup(info->tport.tty); 403 tty_hangup(port->tty);
403 } 404 }
404 } 405 }
405 if (info->tport.flags & ASYNC_CTS_FLOW) { 406 if (port->flags & ASYNC_CTS_FLOW) {
406 if (info->tport.tty->hw_stopped) { 407 if (port->tty->hw_stopped) {
407 if (!(status & SER_CTS)) { 408 if (!(status & SER_CTS)) {
408#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) 409#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
409 printk("CTS tx start..."); 410 printk("CTS tx start...");
410#endif 411#endif
411 info->tport.tty->hw_stopped = 0; 412 port->tty->hw_stopped = 0;
412 info->IER |= UART_IER_THRI; 413 info->IER |= UART_IER_THRI;
413 custom.intena = IF_SETCLR | IF_TBE; 414 custom.intena = IF_SETCLR | IF_TBE;
414 mb(); 415 mb();
415 /* set a pending Tx Interrupt, transmitter should restart now */ 416 /* set a pending Tx Interrupt, transmitter should restart now */
416 custom.intreq = IF_SETCLR | IF_TBE; 417 custom.intreq = IF_SETCLR | IF_TBE;
417 mb(); 418 mb();
418 tty_wakeup(info->tport.tty); 419 tty_wakeup(port->tty);
419 return; 420 return;
420 } 421 }
421 } else { 422 } else {
@@ -423,7 +424,7 @@ static void check_modem_status(struct serial_state *info)
423#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW)) 424#if (defined(SERIAL_DEBUG_INTR) || defined(SERIAL_DEBUG_FLOW))
424 printk("CTS tx stop..."); 425 printk("CTS tx stop...");
425#endif 426#endif
426 info->tport.tty->hw_stopped = 1; 427 port->tty->hw_stopped = 1;
427 info->IER &= ~UART_IER_THRI; 428 info->IER &= ~UART_IER_THRI;
428 /* disable Tx interrupt and remove any pending interrupts */ 429 /* disable Tx interrupt and remove any pending interrupts */
429 custom.intena = IF_TBE; 430 custom.intena = IF_TBE;
@@ -1371,6 +1372,7 @@ static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
1371static void rs_close(struct tty_struct *tty, struct file * filp) 1372static void rs_close(struct tty_struct *tty, struct file * filp)
1372{ 1373{
1373 struct serial_state *state = tty->driver_data; 1374 struct serial_state *state = tty->driver_data;
1375 struct tty_port *port = &state->tport;
1374 unsigned long flags; 1376 unsigned long flags;
1375 1377
1376 if (!state || serial_paranoia_check(state, tty->name, "rs_close")) 1378 if (!state || serial_paranoia_check(state, tty->name, "rs_close"))
@@ -1385,38 +1387,38 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1385 } 1387 }
1386 1388
1387#ifdef SERIAL_DEBUG_OPEN 1389#ifdef SERIAL_DEBUG_OPEN
1388 printk("rs_close ttys%d, count = %d\n", state->line, state->tport.count); 1390 printk("rs_close ttys%d, count = %d\n", state->line, port->count);
1389#endif 1391#endif
1390 if ((tty->count == 1) && (state->tport.count != 1)) { 1392 if ((tty->count == 1) && (port->count != 1)) {
1391 /* 1393 /*
1392 * Uh, oh. tty->count is 1, which means that the tty 1394 * Uh, oh. tty->count is 1, which means that the tty
1393 * structure will be freed. state->tport.count should always 1395 * structure will be freed. port->count should always
1394 * be one in these conditions. If it's greater than 1396 * be one in these conditions. If it's greater than
1395 * one, we've got real problems, since it means the 1397 * one, we've got real problems, since it means the
1396 * serial port won't be shutdown. 1398 * serial port won't be shutdown.
1397 */ 1399 */
1398 printk("rs_close: bad serial port count; tty->count is 1, " 1400 printk("rs_close: bad serial port count; tty->count is 1, "
1399 "state->tport.count is %d\n", state->tport.count); 1401 "port->count is %d\n", state->tport.count);
1400 state->tport.count = 1; 1402 port->count = 1;
1401 } 1403 }
1402 if (--state->tport.count < 0) { 1404 if (--port->count < 0) {
1403 printk("rs_close: bad serial port count for ttys%d: %d\n", 1405 printk("rs_close: bad serial port count for ttys%d: %d\n",
1404 state->line, state->tport.count); 1406 state->line, port->count);
1405 state->tport.count = 0; 1407 port->count = 0;
1406 } 1408 }
1407 if (state->tport.count) { 1409 if (port->count) {
1408 DBG_CNT("before DEC-2"); 1410 DBG_CNT("before DEC-2");
1409 local_irq_restore(flags); 1411 local_irq_restore(flags);
1410 return; 1412 return;
1411 } 1413 }
1412 state->tport.flags |= ASYNC_CLOSING; 1414 port->flags |= ASYNC_CLOSING;
1413 /* 1415 /*
1414 * Now we wait for the transmit buffer to clear; and we notify 1416 * Now we wait for the transmit buffer to clear; and we notify
1415 * the line discipline to only process XON/XOFF characters. 1417 * the line discipline to only process XON/XOFF characters.
1416 */ 1418 */
1417 tty->closing = 1; 1419 tty->closing = 1;
1418 if (state->tport.closing_wait != ASYNC_CLOSING_WAIT_NONE) 1420 if (port->closing_wait != ASYNC_CLOSING_WAIT_NONE)
1419 tty_wait_until_sent(tty, state->tport.closing_wait); 1421 tty_wait_until_sent(tty, port->closing_wait);
1420 /* 1422 /*
1421 * At this point we stop accepting input. To do this, we 1423 * At this point we stop accepting input. To do this, we
1422 * disable the receive line status interrupts, and tell the 1424 * disable the receive line status interrupts, and tell the
@@ -1424,7 +1426,7 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1424 * line status register. 1426 * line status register.
1425 */ 1427 */
1426 state->read_status_mask &= ~UART_LSR_DR; 1428 state->read_status_mask &= ~UART_LSR_DR;
1427 if (state->tport.flags & ASYNC_INITIALIZED) { 1429 if (port->flags & ASYNC_INITIALIZED) {
1428 /* disable receive interrupts */ 1430 /* disable receive interrupts */
1429 custom.intena = IF_RBF; 1431 custom.intena = IF_RBF;
1430 mb(); 1432 mb();
@@ -1444,15 +1446,15 @@ static void rs_close(struct tty_struct *tty, struct file * filp)
1444 1446
1445 tty_ldisc_flush(tty); 1447 tty_ldisc_flush(tty);
1446 tty->closing = 0; 1448 tty->closing = 0;
1447 state->tport.tty = NULL; 1449 port->tty = NULL;
1448 if (state->tport.blocked_open) { 1450 if (port->blocked_open) {
1449 if (state->tport.close_delay) { 1451 if (port->close_delay) {
1450 msleep_interruptible(jiffies_to_msecs(state->tport.close_delay)); 1452 msleep_interruptible(jiffies_to_msecs(port->close_delay));
1451 } 1453 }
1452 wake_up_interruptible(&state->tport.open_wait); 1454 wake_up_interruptible(&port->open_wait);
1453 } 1455 }
1454 state->tport.flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); 1456 port->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
1455 wake_up_interruptible(&state->tport.close_wait); 1457 wake_up_interruptible(&port->close_wait);
1456 local_irq_restore(flags); 1458 local_irq_restore(flags);
1457} 1459}
1458 1460
@@ -1661,29 +1663,30 @@ static int block_til_ready(struct tty_struct *tty, struct file * filp,
1661static int rs_open(struct tty_struct *tty, struct file * filp) 1663static int rs_open(struct tty_struct *tty, struct file * filp)
1662{ 1664{
1663 struct serial_state *info = rs_table + tty->index; 1665 struct serial_state *info = rs_table + tty->index;
1666 struct tty_port *port = &info->tport;
1664 int retval; 1667 int retval;
1665 1668
1666 info->tport.count++; 1669 port->count++;
1667 info->tport.tty = tty; 1670 port->tty = tty;
1668 tty->driver_data = info; 1671 tty->driver_data = info;
1669 tty->port = &info->tport; 1672 tty->port = port;
1670 if (serial_paranoia_check(info, tty->name, "rs_open")) 1673 if (serial_paranoia_check(info, tty->name, "rs_open"))
1671 return -ENODEV; 1674 return -ENODEV;
1672 1675
1673#ifdef SERIAL_DEBUG_OPEN 1676#ifdef SERIAL_DEBUG_OPEN
1674 printk("rs_open %s, count = %d\n", tty->name, info->count); 1677 printk("rs_open %s, count = %d\n", tty->name, info->count);
1675#endif 1678#endif
1676 tty->low_latency = (info->tport.flags & ASYNC_LOW_LATENCY) ? 1 : 0; 1679 tty->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
1677 1680
1678 /* 1681 /*
1679 * If the port is the middle of closing, bail out now 1682 * If the port is the middle of closing, bail out now
1680 */ 1683 */
1681 if (tty_hung_up_p(filp) || 1684 if (tty_hung_up_p(filp) ||
1682 (info->tport.flags & ASYNC_CLOSING)) { 1685 (port->flags & ASYNC_CLOSING)) {
1683 if (info->tport.flags & ASYNC_CLOSING) 1686 if (port->flags & ASYNC_CLOSING)
1684 interruptible_sleep_on(&info->tport.close_wait); 1687 interruptible_sleep_on(&port->close_wait);
1685#ifdef SERIAL_DO_RESTART 1688#ifdef SERIAL_DO_RESTART
1686 return ((info->tport.flags & ASYNC_HUP_NOTIFY) ? 1689 return ((port->flags & ASYNC_HUP_NOTIFY) ?
1687 -EAGAIN : -ERESTARTSYS); 1690 -EAGAIN : -ERESTARTSYS);
1688#else 1691#else
1689 return -EAGAIN; 1692 return -EAGAIN;