From: Alan Cox <alan@lxorguk.ukuu.org.uk>
To: linux-kernel@vger.kernel.org, akpm@osdl.org, greg@kroah.com
Subject: [PATCH 02/20] tty: Clean up tiocmset
Date: Mon, 19 May 2008 15:50:18 +0100 [thread overview]
Message-ID: <20080519145018.19326.15853.stgit@core> (raw)
In-Reply-To: <20080519144557.19326.74313.stgit@core>
From: Alan Cox <alan@redhat.com>
Reverse the order of one test and it gets much more readable
---
drivers/char/tty_io.c | 48 ++++++++++++++++++++++--------------------------
1 files changed, 22 insertions(+), 26 deletions(-)
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index fb17b18..31ab8f0 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -3402,35 +3402,31 @@ static int tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *p
static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int cmd,
unsigned __user *p)
{
- int retval = -EINVAL;
-
- if (tty->ops->tiocmset) {
- unsigned int set, clear, val;
-
- retval = get_user(val, p);
- if (retval)
- return retval;
-
- set = clear = 0;
- switch (cmd) {
- case TIOCMBIS:
- set = val;
- break;
- case TIOCMBIC:
- clear = val;
- break;
- case TIOCMSET:
- set = val;
- clear = ~val;
- break;
- }
+ int retval;
+ unsigned int set, clear, val;
- set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
- clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
+ if (tty->ops->tiocmset == NULL)
+ return -EINVAL;
- retval = tty->ops->tiocmset(tty, file, set, clear);
+ retval = get_user(val, p);
+ if (retval)
+ return retval;
+ set = clear = 0;
+ switch (cmd) {
+ case TIOCMBIS:
+ set = val;
+ break;
+ case TIOCMBIC:
+ clear = val;
+ break;
+ case TIOCMSET:
+ set = val;
+ clear = ~val;
+ break;
}
- return retval;
+ set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
+ clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
+ return tty->ops->tiocmset(tty, file, set, clear);
}
/*
next prev parent reply other threads:[~2008-05-19 15:03 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-19 14:50 [PATCH 00/20] Implment a tty port structure and supporting logic Alan Cox
2008-05-19 14:50 ` [PATCH 01/20] tty: Introduce a tty_port common structure Alan Cox
2008-05-19 17:47 ` Sam Ravnborg
2008-05-19 17:51 ` Greg KH
2008-05-19 19:48 ` Alan Cox
2008-05-19 21:36 ` Greg KH
2008-05-19 14:50 ` Alan Cox [this message]
2008-05-19 14:50 ` [PATCH 03/20] epca: use tty_port Alan Cox
2008-05-19 14:50 ` [PATCH 04/20] isicom: " Alan Cox
2008-05-19 14:50 ` [PATCH 05/20] moxa: " Alan Cox
2008-05-19 14:50 ` [PATCH 06/20] mxser: " Alan Cox
2008-05-19 14:50 ` [PATCH 07/20] riscom8: " Alan Cox
2008-05-19 14:50 ` [PATCH 08/20] rocket: " Alan Cox
2008-05-19 14:50 ` [PATCH 09/20] synclink: " Alan Cox
2008-05-19 14:51 ` [PATCH 10/20] esp: " Alan Cox
2008-05-19 14:51 ` [PATCH 11/20] istallion: " Alan Cox
2008-05-19 14:51 ` [PATCH 12/20] stallion: " Alan Cox
2008-05-19 14:51 ` [PATCH 13/20] cyclades: " Alan Cox
2008-05-19 14:51 ` [PATCH 14/20] gs: " Alan Cox
2008-05-19 14:51 ` [PATCH 15/20] serial: " Alan Cox
2008-05-19 14:51 ` [PATCH 17/20] riscom8: remove bogus checks Alan Cox
2008-05-19 14:51 ` [PATCH 18/20] tty: add more tty_port fields Alan Cox
2008-05-19 14:51 ` [PATCH 19/20] whiteheat: coding style Alan Cox
2008-05-19 14:52 ` [PATCH 20/20] whiteheat: fix bugs found in the tidy and audit Alan Cox
2008-05-19 16:50 ` [PATCH 00/20] Implment a tty port structure and supporting logic Greg KH
2008-05-19 18:27 ` Alan Cox
2008-05-20 8:52 ` Andrew Morton
2008-05-20 17:23 ` Greg KH
2008-05-20 18:53 ` Alan Cox
2008-05-19 22:39 ` Aristeu Rozanski
2008-05-20 8:31 ` Alan Cox
2008-05-27 18:05 ` Greg KH
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=20080519145018.19326.15853.stgit@core \
--to=alan@lxorguk.ukuu.org.uk \
--cc=akpm@osdl.org \
--cc=greg@kroah.com \
--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