Skip to content

Commit

Permalink
n_tty: Merge .receive_buf() flavors
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Peter Hurley authored and Greg Kroah-Hartman committed Dec 9, 2013
1 parent 187094f commit 5c32d12
Showing 1 changed file with 16 additions and 27 deletions.
43 changes: 16 additions & 27 deletions drivers/tty/n_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -1674,32 +1674,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,
char *fp, int count)
{
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)
static int
n_tty_receive_buf_common(struct tty_struct *tty, const unsigned char *cp,
char *fp, int count, int flow)
{
struct n_tty_data *ldata = tty->disc_data;
int room, n, rcvd = 0;
Expand All @@ -1710,7 +1687,7 @@ static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp,
room = receive_room(tty);
n = min(count, room);
if (!n) {
if (!room)
if (flow && !room)
ldata->no_room = 1;
break;
}
Expand All @@ -1729,6 +1706,18 @@ static int n_tty_receive_buf2(struct tty_struct *tty, const unsigned char *cp,
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)
{
return (sigismember(&current->blocked, sig) ||
Expand Down

0 comments on commit 5c32d12

Please sign in to comment.