From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1423286AbbEEVTV (ORCPT ); Tue, 5 May 2015 17:19:21 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:36344 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031518AbbEEUzh (ORCPT ); Tue, 5 May 2015 16:55:37 -0400 From: Kamal Mostafa To: linux-kernel@vger.kernel.org, stable@vger.kernel.org, kernel-team@lists.ubuntu.com Cc: Peter Hurley , Greg Kroah-Hartman , Joseph Salisbury , Kamal Mostafa Subject: [PATCH 3.13.y-ckt 17/90] n_tty: Merge .receive_buf() flavors Date: Tue, 5 May 2015 13:53:49 -0700 Message-Id: <1430859302-5886-18-git-send-email-kamal@canonical.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430859302-5886-1-git-send-email-kamal@canonical.com> References: <1430859302-5886-1-git-send-email-kamal@canonical.com> X-Extended-Stable: 3.13 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.13.11-ckt20 -stable review patch. If anyone has any objections, please let me know. ------------------ From: Peter Hurley commit 5c32d12378313e0096ea0d450462aa638a90fb6e upstream. N_TTY's direct and flow-controlled flavors of the .receive_buf() method are nearly identical; fold together. Signed-off-by: Peter Hurley Signed-off-by: Greg Kroah-Hartman [ kamal: 3.13-stable prereq for fb5ef9e n_tty: Fix read buffer overwrite when no newline ] Cc: Joseph Salisbury Signed-off-by: Kamal Mostafa --- 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 7bdaa14..4b24555 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -1682,32 +1682,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; @@ -1718,7 +1695,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; } @@ -1737,6 +1714,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(¤t->blocked, sig) || -- 1.9.1