Commit d4e321fc authored by Peter Hurley's avatar Peter Hurley Committed by Jiri Slaby

n_tty: Merge .receive_buf() flavors

commit 5c32d123 upstream.

N_TTY's direct and flow-controlled flavors of the .receive_buf()
method are nearly identical; fold together.
Signed-off-by: default avatarPeter Hurley <peter@hurleysoftware.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent 362771fb
...@@ -1683,32 +1683,9 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp, ...@@ -1683,32 +1683,9 @@ static void __receive_buf(struct tty_struct *tty, const unsigned char *cp,
} }
} }
static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp, static int
char *fp, int count) n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp,
{ char *fp, int count, int flow)
int room, n;
down_read(&tty->termios_rwsem);
while (1) {
room = receive_room(tty);
n = min(count, room);
if (!n)
break;
__receive_buf(tty, cp, fp, n);
cp += n;
if (fp)
fp += n;
count -= n;
}
tty->receive_room = room;
n_tty_check_throttle(tty);
up_read(&tty->termios_rwsem);
}
static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count)
{ {
struct n_tty_data *ldata = tty->disc_data; struct n_tty_data *ldata = tty->disc_data;
int room, n, rcvd = 0; int room, n, rcvd = 0;
...@@ -1719,7 +1696,7 @@ static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, ...@@ -1719,7 +1696,7 @@ static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp,
room = receive_room(tty); room = receive_room(tty);
n = min(count, room); n = min(count, room);
if (!n) { if (!n) {
if (!room) if (flow && !room)
ldata->no_room = 1; ldata->no_room = 1;
break; break;
} }
...@@ -1738,6 +1715,18 @@ static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp, ...@@ -1738,6 +1715,18 @@ static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp,
return rcvd; return rcvd;
} }
static void n_tty_receive_buf(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count)
{
n_tty_receive_buf_common(tty, cp, fp, count, 0);
}
static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count)
{
return n_tty_receive_buf_common(tty, cp, fp, count, 1);
}
int is_ignored(int sig) int is_ignored(int sig)
{ {
return (sigismember(&current->blocked, sig) || return (sigismember(&current->blocked, sig) ||
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment