aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_io.c
diff options
context:
space:
mode:
authorAlan Cox <alan@redhat.com>2008-07-16 16:56:54 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-20 20:12:37 -0400
commitae67751785dae388beb31fc24d14870d0d4669d9 (patch)
treec474447cc19bc5b042438c8cf63c9288fd33c8ad /drivers/char/tty_io.c
parent8fb06c771399b8d51d724756411108e9abe2a85a (diff)
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>
Diffstat (limited to 'drivers/char/tty_io.c')
-rw-r--r--drivers/char/tty_io.c48
1 files changed, 22 insertions, 26 deletions
diff --git a/drivers/char/tty_io.c b/drivers/char/tty_io.c
index 739c9c59fc62..a8cc416a23c0 100644
--- a/drivers/char/tty_io.c
+++ b/drivers/char/tty_io.c
@@ -3515,35 +3515,31 @@ static int tty_tiocmget(struct tty_struct *tty, struct file *file, int __user *p
3515static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int cmd, 3515static int tty_tiocmset(struct tty_struct *tty, struct file *file, unsigned int cmd,
3516 unsigned __user *p) 3516 unsigned __user *p)
3517{ 3517{
3518 int retval = -EINVAL; 3518 int retval;
3519 3519 unsigned int set, clear, val;
3520 if (tty->ops->tiocmset) {
3521 unsigned int set, clear, val;
3522
3523 retval = get_user(val, p);
3524 if (retval)
3525 return retval;
3526
3527 set = clear = 0;
3528 switch (cmd) {
3529 case TIOCMBIS:
3530 set = val;
3531 break;
3532 case TIOCMBIC:
3533 clear = val;
3534 break;
3535 case TIOCMSET:
3536 set = val;
3537 clear = ~val;
3538 break;
3539 }
3540 3520
3541 set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP; 3521 if (tty->ops->tiocmset == NULL)
3542 clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP; 3522 return -EINVAL;
3543 3523
3544 retval = tty->ops->tiocmset(tty, file, set, clear); 3524 retval = get_user(val, p);
3525 if (retval)
3526 return retval;
3527 set = clear = 0;
3528 switch (cmd) {
3529 case TIOCMBIS:
3530 set = val;
3531 break;
3532 case TIOCMBIC:
3533 clear = val;
3534 break;
3535 case TIOCMSET:
3536 set = val;
3537 clear = ~val;
3538 break;
3545 } 3539 }
3546 return retval; 3540 set &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
3541 clear &= TIOCM_DTR|TIOCM_RTS|TIOCM_OUT1|TIOCM_OUT2|TIOCM_LOOP;
3542 return tty->ops->tiocmset(tty, file, set, clear);
3547} 3543}
3548 3544
3549/* 3545/*