public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peter Hurley <peter@hurleysoftware.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Jiri Slaby <jslaby@suse.cz>,
	linux-kernel@vger.kernel.org,
	Peter Hurley <peter@hurleysoftware.com>
Subject: [PATCH v2 3/3] n_tty: Reduce branching in canon_copy_from_read_buf()
Date: Fri, 27 Nov 2015 14:11:04 -0500	[thread overview]
Message-ID: <1448651464-4103-4-git-send-email-peter@hurleysoftware.com> (raw)
In-Reply-To: <1448651464-4103-1-git-send-email-peter@hurleysoftware.com>

Instead of compare-and-set, just compute 'found'.

Signed-off-by: Peter Hurley <peter@hurleysoftware.com>
---
 drivers/tty/n_tty.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c
index eab606a..9b0b610 100644
--- a/drivers/tty/n_tty.c
+++ b/drivers/tty/n_tty.c
@@ -2079,10 +2079,9 @@ static int canon_copy_from_read_buf(struct tty_struct *tty,
 	if (eol == N_TTY_BUF_SIZE && more) {
 		/* scan wrapped without finding set bit */
 		eol = find_next_bit(ldata->read_flags, more, 0);
-		if (eol != more)
-			found = 1;
-	} else if (eol != size)
-		found = 1;
+		found = eol != more;
+	} else
+		found = eol != size;
 
 	n = eol - tail;
 	if (n > N_TTY_BUF_SIZE)
-- 
2.6.3


      parent reply	other threads:[~2015-11-27 19:11 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-08 14:35 [PATCH] n_tty: Clarify copy_from_read_buf() Peter Hurley
2015-11-08 14:35 ` [PATCH] n_tty: Uninline tty_copy_to_user() Peter Hurley
2015-11-27 19:11 ` [PATCH v2 0/3] n_tty_read() helper cleanups Peter Hurley
2015-11-27 19:11   ` [PATCH v2 1/3] n_tty: Uninline tty_copy_to_user() Peter Hurley
2015-11-27 19:11   ` [PATCH v2 2/3] n_tty: Clarify copy_from_read_buf() Peter Hurley
2015-11-27 19:11   ` Peter Hurley [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1448651464-4103-4-git-send-email-peter@hurleysoftware.com \
    --to=peter@hurleysoftware.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jslaby@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox