lkml.org 
[lkml]   [2013]   [Nov]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH tty-next 1/7] n_tty: Merge .receive_buf() flavors
    Date
    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>
    ---
    drivers/tty/n_tty.c | 43 ++++++++++++++++---------------------------
    1 file changed, 16 insertions(+), 27 deletions(-)

    diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
    index 5f1c5f3..3eb54c7 100644
    --- a/drivers/tty/n_tty.c
    +++ b/drivers/tty/n_tty.c
    @@ -1675,32 +1675,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;
    @@ -1711,7 +1688,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;
    }
    @@ -1730,6 +1707,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) ||
    --
    1.8.1.2


    \
     
     \ /
      Last update: 2013-11-22 17:21    [W:4.234 / U:0.344 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site