summaryrefslogtreecommitdiffstats
path: root/drivers/char/tty_ioctl.c
diff options
context:
space:
mode:
authorAlan Cox <alan@lxorguk.ukuu.org.uk>2008-04-30 00:53:34 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-04-30 08:29:41 -0700
commit1c2630ccf922b7ea2c54c184243d4fb2bd2cf3c6 (patch)
tree205b3180561c253f5af49dfe261dbc539b6108d8 /drivers/char/tty_ioctl.c
parent0ee9cbb3c705903db9c258047d9ce87096e6a1a1 (diff)
downloadop-kernel-dev-1c2630ccf922b7ea2c54c184243d4fb2bd2cf3c6.zip
op-kernel-dev-1c2630ccf922b7ea2c54c184243d4fb2bd2cf3c6.tar.gz
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.c33
1 files changed, 27 insertions, 6 deletions
diff --git a/drivers/char/tty_ioctl.c b/drivers/char/tty_ioctl.c
index 851cfcd..d769e43 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)
}
/**
+ * tty_change_softcar - carrier change ioctl helper
+ * @tty: tty to update
+ * @arg: enable/disable CLOCAL
+ *
+ * Perform a change to the CLOCAL state and call into the driver
+ * layer to make it visible. All done with the termios mutex
+ */
+
+static int tty_change_softcar(struct tty_struct *tty, int arg)
+{
+ int ret = 0;
+ int bit = arg ? CLOCAL : 0;
+ struct ktermios old = *tty->termios;
+
+ mutex_lock(&tty->termios_mutex);
+ tty->termios->c_cflag &= ~CLOCAL;
+ tty->termios->c_cflag |= bit;
+ if (tty->driver->set_termios)
+ tty->driver->set_termios(tty, &old);
+ if ((tty->termios->c_cflag & CLOCAL) != bit)
+ ret = -EINVAL;
+ mutex_unlock(&tty->termios_mutex);
+ return ret;
+}
+
+/**
* tty_mode_ioctl - mode related ioctls
* @tty: tty for the ioctl
* @file: file pointer for the tty
@@ -865,12 +891,7 @@ int tty_mode_ioctl(struct tty_struct *tty, struct file *file,
case TIOCSSOFTCAR:
if (get_user(arg, (unsigned int __user *) arg))
return -EFAULT;
- mutex_lock(&tty->termios_mutex);
- tty->termios->c_cflag =
- ((tty->termios->c_cflag & ~CLOCAL) |
- (arg ? CLOCAL : 0));
- mutex_unlock(&tty->termios_mutex);
- return 0;
+ return tty_change_softcar(tty, arg);
default:
return -ENOIOCTLCMD;
}
OpenPOWER on IntegriCloud