tty: Clean up tiocmset

Reverse the order of one test and it gets much more readable

Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Alan Cox 2008-07-16 21:56:54 +01:00 committed by Linus Torvalds
parent 8fb06c7713
commit ae67751785
1 changed files with 22 additions and 26 deletions

View File

@ -3515,35 +3515,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, static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int cmd,
unsigned __user *p) unsigned __user *p)
{ {
int retval = -EINVAL; int retval;
unsigned int set, clear, val;
if (tty->ops->tiocmset) { if (tty->ops->tiocmset == NULL)
unsigned int set, clear, val; return -EINVAL;
retval = get_user(val, p); retval = get_user(val, p);
if (retval) if (retval)
return retval; return retval;
set = clear = 0;
set = clear = 0; switch (cmd) {
switch (cmd) { case TIOCMBIS:
case TIOCMBIS: set = val;
set = val; break;
break; case TIOCMBIC:
case TIOCMBIC: clear = val;
clear = val; break;
break; case TIOCMSET:
case TIOCMSET: set = val;
set = val; clear = ~val;
clear = ~val; break;
break;
}
set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
retval = tty->ops->tiocmset(tty, file, set, clear);
} }
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);
} }
/* /*