diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-04-02 07:53:59 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-04-09 14:16:55 -0400 |
commit | 265d6f00e79166c145421cbca06a20f33332b29f (patch) | |
tree | 23f17d990c45937e4282705c2c385c4c9d326fe5 /drivers/isdn/i4l | |
parent | 82e46b31908244678a6e7404c4204dd3f6fea9f0 (diff) |
TTY: isdn, define local tty_port
In some functions we use tty_port much. So let us have a local pointer
to that variable instead of having info->port all over the code.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Karsten Keil <isdn@linux-pingi.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/isdn/i4l')
-rw-r--r-- | drivers/isdn/i4l/isdn_tty.c | 98 |
1 files changed, 52 insertions, 46 deletions
diff --git a/drivers/isdn/i4l/isdn_tty.c b/drivers/isdn/i4l/isdn_tty.c index dfb83e68bd86..ee8ba87ac524 100644 --- a/drivers/isdn/i4l/isdn_tty.c +++ b/drivers/isdn/i4l/isdn_tty.c | |||
@@ -1003,20 +1003,21 @@ isdn_tty_paranoia_check(modem_info *info, char *name, const char *routine) | |||
1003 | static void | 1003 | static void |
1004 | isdn_tty_change_speed(modem_info *info) | 1004 | isdn_tty_change_speed(modem_info *info) |
1005 | { | 1005 | { |
1006 | struct tty_port *port = &info->port; | ||
1006 | uint cflag, | 1007 | uint cflag, |
1007 | cval, | 1008 | cval, |
1008 | quot; | 1009 | quot; |
1009 | int i; | 1010 | int i; |
1010 | 1011 | ||
1011 | if (!info->port.tty || !info->port.tty->termios) | 1012 | if (!port->tty || !port->tty->termios) |
1012 | return; | 1013 | return; |
1013 | cflag = info->port.tty->termios->c_cflag; | 1014 | cflag = port->tty->termios->c_cflag; |
1014 | 1015 | ||
1015 | quot = i = cflag & CBAUD; | 1016 | quot = i = cflag & CBAUD; |
1016 | if (i & CBAUDEX) { | 1017 | if (i & CBAUDEX) { |
1017 | i &= ~CBAUDEX; | 1018 | i &= ~CBAUDEX; |
1018 | if (i < 1 || i > 2) | 1019 | if (i < 1 || i > 2) |
1019 | info->port.tty->termios->c_cflag &= ~CBAUDEX; | 1020 | port->tty->termios->c_cflag &= ~CBAUDEX; |
1020 | else | 1021 | else |
1021 | i += 15; | 1022 | i += 15; |
1022 | } | 1023 | } |
@@ -1046,13 +1047,13 @@ isdn_tty_change_speed(modem_info *info) | |||
1046 | 1047 | ||
1047 | /* CTS flow control flag and modem status interrupts */ | 1048 | /* CTS flow control flag and modem status interrupts */ |
1048 | if (cflag & CRTSCTS) { | 1049 | if (cflag & CRTSCTS) { |
1049 | info->port.flags |= ASYNC_CTS_FLOW; | 1050 | port->flags |= ASYNC_CTS_FLOW; |
1050 | } else | 1051 | } else |
1051 | info->port.flags &= ~ASYNC_CTS_FLOW; | 1052 | port->flags &= ~ASYNC_CTS_FLOW; |
1052 | if (cflag & CLOCAL) | 1053 | if (cflag & CLOCAL) |
1053 | info->port.flags &= ~ASYNC_CHECK_CD; | 1054 | port->flags &= ~ASYNC_CHECK_CD; |
1054 | else { | 1055 | else { |
1055 | info->port.flags |= ASYNC_CHECK_CD; | 1056 | port->flags |= ASYNC_CHECK_CD; |
1056 | } | 1057 | } |
1057 | } | 1058 | } |
1058 | 1059 | ||
@@ -1487,6 +1488,7 @@ isdn_tty_set_termios(struct tty_struct *tty, struct ktermios *old_termios) | |||
1487 | static int | 1488 | static int |
1488 | isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *info) | 1489 | isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info *info) |
1489 | { | 1490 | { |
1491 | struct tty_port *port = &info->port; | ||
1490 | DECLARE_WAITQUEUE(wait, NULL); | 1492 | DECLARE_WAITQUEUE(wait, NULL); |
1491 | int do_clocal = 0; | 1493 | int do_clocal = 0; |
1492 | int retval; | 1494 | int retval; |
@@ -1496,11 +1498,11 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * | |||
1496 | * until it's done, and then try again. | 1498 | * until it's done, and then try again. |
1497 | */ | 1499 | */ |
1498 | if (tty_hung_up_p(filp) || | 1500 | if (tty_hung_up_p(filp) || |
1499 | (info->port.flags & ASYNC_CLOSING)) { | 1501 | (port->flags & ASYNC_CLOSING)) { |
1500 | if (info->port.flags & ASYNC_CLOSING) | 1502 | if (port->flags & ASYNC_CLOSING) |
1501 | interruptible_sleep_on(&info->port.close_wait); | 1503 | interruptible_sleep_on(&port->close_wait); |
1502 | #ifdef MODEM_DO_RESTART | 1504 | #ifdef MODEM_DO_RESTART |
1503 | if (info->port.flags & ASYNC_HUP_NOTIFY) | 1505 | if (port->flags & ASYNC_HUP_NOTIFY) |
1504 | return -EAGAIN; | 1506 | return -EAGAIN; |
1505 | else | 1507 | else |
1506 | return -ERESTARTSYS; | 1508 | return -ERESTARTSYS; |
@@ -1514,7 +1516,7 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * | |||
1514 | */ | 1516 | */ |
1515 | if ((filp->f_flags & O_NONBLOCK) || | 1517 | if ((filp->f_flags & O_NONBLOCK) || |
1516 | (tty->flags & (1 << TTY_IO_ERROR))) { | 1518 | (tty->flags & (1 << TTY_IO_ERROR))) { |
1517 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 1519 | port->flags |= ASYNC_NORMAL_ACTIVE; |
1518 | return 0; | 1520 | return 0; |
1519 | } | 1521 | } |
1520 | if (tty->termios->c_cflag & CLOCAL) | 1522 | if (tty->termios->c_cflag & CLOCAL) |
@@ -1527,20 +1529,20 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * | |||
1527 | * exit, either normal or abnormal. | 1529 | * exit, either normal or abnormal. |
1528 | */ | 1530 | */ |
1529 | retval = 0; | 1531 | retval = 0; |
1530 | add_wait_queue(&info->port.open_wait, &wait); | 1532 | add_wait_queue(&port->open_wait, &wait); |
1531 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1533 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1532 | printk(KERN_DEBUG "isdn_tty_block_til_ready before block: ttyi%d, count = %d\n", | 1534 | printk(KERN_DEBUG "isdn_tty_block_til_ready before block: ttyi%d, count = %d\n", |
1533 | info->line, info->count); | 1535 | info->line, info->count); |
1534 | #endif | 1536 | #endif |
1535 | if (!(tty_hung_up_p(filp))) | 1537 | if (!(tty_hung_up_p(filp))) |
1536 | info->port.count--; | 1538 | port->count--; |
1537 | info->port.blocked_open++; | 1539 | port->blocked_open++; |
1538 | while (1) { | 1540 | while (1) { |
1539 | set_current_state(TASK_INTERRUPTIBLE); | 1541 | set_current_state(TASK_INTERRUPTIBLE); |
1540 | if (tty_hung_up_p(filp) || | 1542 | if (tty_hung_up_p(filp) || |
1541 | !(info->port.flags & ASYNC_INITIALIZED)) { | 1543 | !(port->flags & ASYNC_INITIALIZED)) { |
1542 | #ifdef MODEM_DO_RESTART | 1544 | #ifdef MODEM_DO_RESTART |
1543 | if (info->port.flags & ASYNC_HUP_NOTIFY) | 1545 | if (port->flags & ASYNC_HUP_NOTIFY) |
1544 | retval = -EAGAIN; | 1546 | retval = -EAGAIN; |
1545 | else | 1547 | else |
1546 | retval = -ERESTARTSYS; | 1548 | retval = -ERESTARTSYS; |
@@ -1549,7 +1551,7 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * | |||
1549 | #endif | 1551 | #endif |
1550 | break; | 1552 | break; |
1551 | } | 1553 | } |
1552 | if (!(info->port.flags & ASYNC_CLOSING) && | 1554 | if (!(port->flags & ASYNC_CLOSING) && |
1553 | (do_clocal || (info->msr & UART_MSR_DCD))) { | 1555 | (do_clocal || (info->msr & UART_MSR_DCD))) { |
1554 | break; | 1556 | break; |
1555 | } | 1557 | } |
@@ -1559,22 +1561,22 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * | |||
1559 | } | 1561 | } |
1560 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1562 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1561 | printk(KERN_DEBUG "isdn_tty_block_til_ready blocking: ttyi%d, count = %d\n", | 1563 | printk(KERN_DEBUG "isdn_tty_block_til_ready blocking: ttyi%d, count = %d\n", |
1562 | info->line, info->port.count); | 1564 | info->line, port->count); |
1563 | #endif | 1565 | #endif |
1564 | schedule(); | 1566 | schedule(); |
1565 | } | 1567 | } |
1566 | current->state = TASK_RUNNING; | 1568 | current->state = TASK_RUNNING; |
1567 | remove_wait_queue(&info->port.open_wait, &wait); | 1569 | remove_wait_queue(&port->open_wait, &wait); |
1568 | if (!tty_hung_up_p(filp)) | 1570 | if (!tty_hung_up_p(filp)) |
1569 | info->port.count++; | 1571 | port->count++; |
1570 | info->port.blocked_open--; | 1572 | port->blocked_open--; |
1571 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1573 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1572 | printk(KERN_DEBUG "isdn_tty_block_til_ready after blocking: ttyi%d, count = %d\n", | 1574 | printk(KERN_DEBUG "isdn_tty_block_til_ready after blocking: ttyi%d, count = %d\n", |
1573 | info->line, info->port.count); | 1575 | info->line, port->count); |
1574 | #endif | 1576 | #endif |
1575 | if (retval) | 1577 | if (retval) |
1576 | return retval; | 1578 | return retval; |
1577 | info->port.flags |= ASYNC_NORMAL_ACTIVE; | 1579 | port->flags |= ASYNC_NORMAL_ACTIVE; |
1578 | return 0; | 1580 | return 0; |
1579 | } | 1581 | } |
1580 | 1582 | ||
@@ -1587,20 +1589,22 @@ isdn_tty_block_til_ready(struct tty_struct *tty, struct file *filp, modem_info * | |||
1587 | static int | 1589 | static int |
1588 | isdn_tty_open(struct tty_struct *tty, struct file *filp) | 1590 | isdn_tty_open(struct tty_struct *tty, struct file *filp) |
1589 | { | 1591 | { |
1592 | struct tty_port *port; | ||
1590 | modem_info *info; | 1593 | modem_info *info; |
1591 | int retval; | 1594 | int retval; |
1592 | 1595 | ||
1593 | info = &dev->mdm.info[tty->index]; | 1596 | info = &dev->mdm.info[tty->index]; |
1594 | if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open")) | 1597 | if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_open")) |
1595 | return -ENODEV; | 1598 | return -ENODEV; |
1599 | port = &info->port; | ||
1596 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1600 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1597 | printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, | 1601 | printk(KERN_DEBUG "isdn_tty_open %s, count = %d\n", tty->name, |
1598 | info->port.count); | 1602 | port->count); |
1599 | #endif | 1603 | #endif |
1600 | info->port.count++; | 1604 | port->count++; |
1601 | tty->driver_data = info; | 1605 | tty->driver_data = info; |
1602 | info->port.tty = tty; | 1606 | port->tty = tty; |
1603 | tty->port = &info->port; | 1607 | tty->port = port; |
1604 | /* | 1608 | /* |
1605 | * Start up serial port | 1609 | * Start up serial port |
1606 | */ | 1610 | */ |
@@ -1632,6 +1636,7 @@ static void | |||
1632 | isdn_tty_close(struct tty_struct *tty, struct file *filp) | 1636 | isdn_tty_close(struct tty_struct *tty, struct file *filp) |
1633 | { | 1637 | { |
1634 | modem_info *info = (modem_info *) tty->driver_data; | 1638 | modem_info *info = (modem_info *) tty->driver_data; |
1639 | struct tty_port *port = &info->port; | ||
1635 | ulong timeout; | 1640 | ulong timeout; |
1636 | 1641 | ||
1637 | if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close")) | 1642 | if (!info || isdn_tty_paranoia_check(info, tty->name, "isdn_tty_close")) |
@@ -1642,7 +1647,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1642 | #endif | 1647 | #endif |
1643 | return; | 1648 | return; |
1644 | } | 1649 | } |
1645 | if ((tty->count == 1) && (info->port.count != 1)) { | 1650 | if ((tty->count == 1) && (port->count != 1)) { |
1646 | /* | 1651 | /* |
1647 | * Uh, oh. tty->count is 1, which means that the tty | 1652 | * Uh, oh. tty->count is 1, which means that the tty |
1648 | * structure will be freed. Info->count should always | 1653 | * structure will be freed. Info->count should always |
@@ -1651,21 +1656,21 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1651 | * serial port won't be shutdown. | 1656 | * serial port won't be shutdown. |
1652 | */ | 1657 | */ |
1653 | printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, " | 1658 | printk(KERN_ERR "isdn_tty_close: bad port count; tty->count is 1, " |
1654 | "info->count is %d\n", info->port.count); | 1659 | "info->count is %d\n", port->count); |
1655 | info->port.count = 1; | 1660 | port->count = 1; |
1656 | } | 1661 | } |
1657 | if (--info->port.count < 0) { | 1662 | if (--port->count < 0) { |
1658 | printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n", | 1663 | printk(KERN_ERR "isdn_tty_close: bad port count for ttyi%d: %d\n", |
1659 | info->line, info->port.count); | 1664 | info->line, port->count); |
1660 | info->port.count = 0; | 1665 | port->count = 0; |
1661 | } | 1666 | } |
1662 | if (info->port.count) { | 1667 | if (port->count) { |
1663 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1668 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1664 | printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n"); | 1669 | printk(KERN_DEBUG "isdn_tty_close after info->count != 0\n"); |
1665 | #endif | 1670 | #endif |
1666 | return; | 1671 | return; |
1667 | } | 1672 | } |
1668 | info->port.flags |= ASYNC_CLOSING; | 1673 | port->flags |= ASYNC_CLOSING; |
1669 | 1674 | ||
1670 | tty->closing = 1; | 1675 | tty->closing = 1; |
1671 | /* | 1676 | /* |
@@ -1674,7 +1679,7 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1674 | * interrupt driver to stop checking the data ready bit in the | 1679 | * interrupt driver to stop checking the data ready bit in the |
1675 | * line status register. | 1680 | * line status register. |
1676 | */ | 1681 | */ |
1677 | if (info->port.flags & ASYNC_INITIALIZED) { | 1682 | if (port->flags & ASYNC_INITIALIZED) { |
1678 | tty_wait_until_sent_from_close(tty, 3000); /* 30 seconds timeout */ | 1683 | tty_wait_until_sent_from_close(tty, 3000); /* 30 seconds timeout */ |
1679 | /* | 1684 | /* |
1680 | * Before we drop DTR, make sure the UART transmitter | 1685 | * Before we drop DTR, make sure the UART transmitter |
@@ -1692,15 +1697,15 @@ isdn_tty_close(struct tty_struct *tty, struct file *filp) | |||
1692 | isdn_tty_shutdown(info); | 1697 | isdn_tty_shutdown(info); |
1693 | isdn_tty_flush_buffer(tty); | 1698 | isdn_tty_flush_buffer(tty); |
1694 | tty_ldisc_flush(tty); | 1699 | tty_ldisc_flush(tty); |
1695 | info->port.tty = NULL; | 1700 | port->tty = NULL; |
1696 | info->ncarrier = 0; | 1701 | info->ncarrier = 0; |
1697 | tty->closing = 0; | 1702 | tty->closing = 0; |
1698 | if (info->port.blocked_open) { | 1703 | if (port->blocked_open) { |
1699 | msleep_interruptible(500); | 1704 | msleep_interruptible(500); |
1700 | wake_up_interruptible(&info->port.open_wait); | 1705 | wake_up_interruptible(&port->open_wait); |
1701 | } | 1706 | } |
1702 | info->port.flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); | 1707 | port->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); |
1703 | wake_up_interruptible(&info->port.close_wait); | 1708 | wake_up_interruptible(&port->close_wait); |
1704 | #ifdef ISDN_DEBUG_MODEM_OPEN | 1709 | #ifdef ISDN_DEBUG_MODEM_OPEN |
1705 | printk(KERN_DEBUG "isdn_tty_close normal exit\n"); | 1710 | printk(KERN_DEBUG "isdn_tty_close normal exit\n"); |
1706 | #endif | 1711 | #endif |
@@ -1713,14 +1718,15 @@ static void | |||
1713 | isdn_tty_hangup(struct tty_struct *tty) | 1718 | isdn_tty_hangup(struct tty_struct *tty) |
1714 | { | 1719 | { |
1715 | modem_info *info = (modem_info *) tty->driver_data; | 1720 | modem_info *info = (modem_info *) tty->driver_data; |
1721 | struct tty_port *port = &info->port; | ||
1716 | 1722 | ||
1717 | if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup")) | 1723 | if (isdn_tty_paranoia_check(info, tty->name, "isdn_tty_hangup")) |
1718 | return; | 1724 | return; |
1719 | isdn_tty_shutdown(info); | 1725 | isdn_tty_shutdown(info); |
1720 | info->port.count = 0; | 1726 | port->count = 0; |
1721 | info->port.flags &= ~ASYNC_NORMAL_ACTIVE; | 1727 | port->flags &= ~ASYNC_NORMAL_ACTIVE; |
1722 | info->port.tty = NULL; | 1728 | port->tty = NULL; |
1723 | wake_up_interruptible(&info->port.open_wait); | 1729 | wake_up_interruptible(&port->open_wait); |
1724 | } | 1730 | } |
1725 | 1731 | ||
1726 | /* This routine initializes all emulator-data. | 1732 | /* This routine initializes all emulator-data. |