diff options
author | Peter Hurley <peter@hurleysoftware.com> | 2013-12-02 14:24:41 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-12-08 19:51:07 -0500 |
commit | 5c32d12378313e0096ea0d450462aa638a90fb6e (patch) | |
tree | 76d06fd377205cc71feccde450157560e2f26697 /drivers/tty/n_tty.c | |
parent | 187094feeb77b5f49513f6a1cfe12749c080bd96 (diff) |
n_tty: Merge .receive_buf() flavors
N_TTY's direct and flow-controlled flavors of the .receive_buf()
method are nearly identical; fold together.
Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/n_tty.c')
-rw-r--r-- | drivers/tty/n_tty.c | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 0f74945af624..cf22bef62c98 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c | |||
@@ -1674,32 +1674,9 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp, | |||
1674 | } | 1674 | } |
1675 | } | 1675 | } |
1676 | 1676 | ||
1677 | static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, | 1677 | static int |
1678 | char *fp, int count) | 1678 | n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp, |
1679 | { | 1679 | char *fp, int count, int flow) |
1680 | int room, n; | ||
1681 | |||
1682 | down_read(&tty->termios_rwsem); | ||
1683 | |||
1684 | while (1) { | ||
1685 | room = receive_room(tty); | ||
1686 | n = min(count, room); | ||
1687 | if (!n) | ||
1688 | break; | ||
1689 | __receive_buf(tty, cp, fp, n); | ||
1690 | cp += n; | ||
1691 | if (fp) | ||
1692 | fp += n; | ||
1693 | count -= n; | ||
1694 | } | ||
1695 | |||
1696 | tty->receive_room = room; | ||
1697 | n_tty_check_throttle(tty); | ||
1698 | up_read(&tty->termios_rwsem); | ||
1699 | } | ||
1700 | |||
1701 | static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, | ||
1702 | char *fp, int count) | ||
1703 | { | 1680 | { |
1704 | struct n_tty_data *ldata = tty->disc_data; | 1681 | struct n_tty_data *ldata = tty->disc_data; |
1705 | int room, n, rcvd = 0; | 1682 | int room, n, rcvd = 0; |
@@ -1710,7 +1687,7 @@ static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, | |||
1710 | room = receive_room(tty); | 1687 | room = receive_room(tty); |
1711 | n = min(count, room); | 1688 | n = min(count, room); |
1712 | if (!n) { | 1689 | if (!n) { |
1713 | if (!room) | 1690 | if (flow && !room) |
1714 | ldata->no_room = 1; | 1691 | ldata->no_room = 1; |
1715 | break; | 1692 | break; |
1716 | } | 1693 | } |
@@ -1729,6 +1706,18 @@ static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, | |||
1729 | return rcvd; | 1706 | return rcvd; |
1730 | } | 1707 | } |
1731 | 1708 | ||
1709 | static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, | ||
1710 | char *fp, int count) | ||
1711 | { | ||
1712 | n_tty_receive_buf_common(tty, cp, fp, count, 0); | ||
1713 | } | ||
1714 | |||
1715 | static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, | ||
1716 | char *fp, int count) | ||
1717 | { | ||
1718 | return n_tty_receive_buf_common(tty, cp, fp, count, 1); | ||
1719 | } | ||
1720 | |||
1732 | int is_ignored(int sig) | 1721 | int is_ignored(int sig) |
1733 | { | 1722 | { |
1734 | return (sigismember(¤t->blocked, sig) || | 1723 | return (sigismember(¤t->blocked, sig) || |