diff options
author | Alan Cox <alan@lxorguk.ukuu.org.uk> | 2008-04-30 03:53:34 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-04-30 11:29:41 -0400 |
commit | 1c2630ccf922b7ea2c54c184243d4fb2bd2cf3c6 (patch) | |
tree | 205b3180561c253f5af49dfe261dbc539b6108d8 /drivers/char/tty_ioctl.c | |
parent | 0ee9cbb3c705903db9c258047d9ce87096e6a1a1 (diff) |
tty_ioctl: soft carrier handling
First cut at moving the soft carrier handling knowledge entirely into the core
code. One or two drivers still needed to snoop these functions to track
CLOCAL internally. Instead make TIOCSSOFTCAR generate the same driver calls
as other termios ioctls changing the clocal flag. This allows us to remove
any driver knowledge and special casing. Also while we are at it we can fix
the error handling.
Signed-off-by: Alan Cox <alan@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/char/tty_ioctl.c')
-rw-r--r-- | drivers/char/tty_ioctl.c | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c index 851cfcd2702a..d769e43f73fb 100644 --- a/drivers/char/tty_ioctl.c +++ b/drivers/char/tty_ioctl.c | |||
@@ -756,6 +756,32 @@ static int send_prio_char(struct tty_struct *tty, char ch) | |||
756 | } | 756 | } |
757 | 757 | ||
758 | /** | 758 | /** |
759 | * tty_change_softcar - carrier change ioctl helper | ||
760 | * @tty: tty to update | ||
761 | * @arg: enable/disable CLOCAL | ||
762 | * | ||
763 | * Perform a change to the CLOCAL state and call into the driver | ||
764 | * layer to make it visible. All done with the termios mutex | ||
765 | */ | ||
766 | |||
767 | static int tty_change_softcar(struct tty_struct *tty, int arg) | ||
768 | { | ||
769 | int ret = 0; | ||
770 | int bit = arg ? CLOCAL : 0; | ||
771 | struct ktermios old = *tty->termios; | ||
772 | |||
773 | mutex_lock(&tty->termios_mutex); | ||
774 | tty->termios->c_cflag &= ~CLOCAL; | ||
775 | tty->termios->c_cflag |= bit; | ||
776 | if (tty->driver->set_termios) | ||
777 | tty->driver->set_termios(tty, &old); | ||
778 | if ((tty->termios->c_cflag & CLOCAL) != bit) | ||
779 | ret = -EINVAL; | ||
780 | mutex_unlock(&tty->termios_mutex); | ||
781 | return ret; | ||
782 | } | ||
783 | |||
784 | /** | ||
759 | * tty_mode_ioctl - mode related ioctls | 785 | * tty_mode_ioctl - mode related ioctls |
760 | * @tty: tty for the ioctl | 786 | * @tty: tty for the ioctl |
761 | * @file: file pointer for the tty | 787 | * @file: file pointer for the tty |
@@ -865,12 +891,7 @@ int tty_mode_ioctl(struct tty_struct *tty, struct file *file, | |||
865 | case TIOCSSOFTCAR: | 891 | case TIOCSSOFTCAR: |
866 | if (get_user(arg, (unsigned int __user *) arg)) | 892 | if (get_user(arg, (unsigned int __user *) arg)) |
867 | return -EFAULT; | 893 | return -EFAULT; |
868 | mutex_lock(&tty->termios_mutex); | 894 | return tty_change_softcar(tty, arg); |
869 | tty->termios->c_cflag = | ||
870 | ((tty->termios->c_cflag & ~CLOCAL) | | ||
871 | (arg ? CLOCAL : 0)); | ||
872 | mutex_unlock(&tty->termios_mutex); | ||
873 | return 0; | ||
874 | default: | 895 | default: |
875 | return -ENOIOCTLCMD; | 896 | return -ENOIOCTLCMD; |
876 | } | 897 | } |