diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-24 16:43:41 +0300 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-24 16:43:41 +0300 |
commit | 44adbac8f7217040be97928cd19998259d9d4418 (patch) | |
tree | c1c6ac9aa4d47801dc9133d6d641286631a8f4b4 /drivers/tty/serial | |
parent | 08ffb584d9eb17940321317ef6c9c7383ad4f149 (diff) | |
parent | ce5a983191ce466cbe35e240ac09e28cca3e50c9 (diff) | |
download | linux-44adbac8f7217040be97928cd19998259d9d4418.tar.xz |
Merge branch 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull tty ioctl updates from Al Viro:
"This is the compat_ioctl work related to tty ioctls.
Quite a bit of dead code taken out, all tty-related stuff gone from
fs/compat_ioctl.c. A bunch of compat bugs fixed - some still remain,
but all more or less generic tty-related ioctls should be covered
(remaining issues are in things like driver-private ioctls in a pcmcia
serial card driver not getting properly handled in 32bit processes on
64bit host, etc)"
* 'work.tty-ioctl' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (53 commits)
kill TIOCSERGSTRUCT
change semantics of ldisc ->compat_ioctl()
kill TIOCSER[SG]WILD
synclink_gt(): fix compat_ioctl()
pty: fix compat ioctls
compat_ioctl - kill keyboard ioctl handling
gigaset: add ->compat_ioctl()
vt_compat_ioctl(): clean up, use compat_ptr() properly
gigaset: don't try to printk userland buffer contents
dgnc: don't bother with (empty) stub for TCXONC
dgnc: leave TIOC[GS]SOFTCAR to ldisc
remove fallback to drivers for TIOCGICOUNT
dgnc: break-related ioctls won't reach ->ioctl()
kill the rest of tty COMPAT_IOCTL() entries
dgnc: TIOCM... won't reach ->ioctl()
isdn_tty: TCSBRK{,P} won't reach ->ioctl()
kill capinc_tty_ioctl()
take compat TIOC[SG]SERIAL treatment into tty_compat_ioctl()
synclink: reduce pointless checks in ->ioctl()
complete ->[sg]et_serial() switchover
...
Diffstat (limited to 'drivers/tty/serial')
-rw-r--r-- | drivers/tty/serial/serial_core.c | 43 |
1 files changed, 12 insertions, 31 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 80bb56facfb6..54726c3f74c6 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c @@ -778,17 +778,13 @@ out: return ret; } -static int uart_get_info_user(struct tty_port *port, - struct serial_struct __user *retinfo) +static int uart_get_info_user(struct tty_struct *tty, + struct serial_struct *ss) { - struct serial_struct tmp; - - if (uart_get_info(port, &tmp) < 0) - return -EIO; + struct uart_state *state = tty->driver_data; + struct tty_port *port = &state->port; - if (copy_to_user(retinfo, &tmp, sizeof(*retinfo))) - return -EFAULT; - return 0; + return uart_get_info(port, ss) < 0 ? -EIO : 0; } static int uart_set_info(struct tty_struct *tty, struct tty_port *port, @@ -990,16 +986,13 @@ static int uart_set_info(struct tty_struct *tty, struct tty_port *port, return retval; } -static int uart_set_info_user(struct tty_struct *tty, struct uart_state *state, - struct serial_struct __user *newinfo) +static int uart_set_info_user(struct tty_struct *tty, struct serial_struct *ss) { - struct serial_struct new_serial; + struct uart_state *state = tty->driver_data; struct tty_port *port = &state->port; int retval; - if (copy_from_user(&new_serial, newinfo, sizeof(new_serial))) - return -EFAULT; - + down_write(&tty->termios_rwsem); /* * This semaphore protects port->count. It is also * very useful to prevent opens. Also, take the @@ -1008,8 +1001,9 @@ static int uart_set_info_user(struct tty_struct *tty, struct uart_state *state, * under us. */ mutex_lock(&port->mutex); - retval = uart_set_info(tty, port, state, &new_serial); + retval = uart_set_info(tty, port, state, ss); mutex_unlock(&port->mutex); + up_write(&tty->termios_rwsem); return retval; } @@ -1325,26 +1319,11 @@ uart_ioctl(struct tty_struct *tty, unsigned int cmd, unsigned long arg) * These ioctls don't rely on the hardware to be present. */ switch (cmd) { - case TIOCGSERIAL: - ret = uart_get_info_user(port, uarg); - break; - - case TIOCSSERIAL: - down_write(&tty->termios_rwsem); - ret = uart_set_info_user(tty, state, uarg); - up_write(&tty->termios_rwsem); - break; - case TIOCSERCONFIG: down_write(&tty->termios_rwsem); ret = uart_do_autoconfig(tty, state); up_write(&tty->termios_rwsem); break; - - case TIOCSERGWILD: /* obsolete */ - case TIOCSERSWILD: /* obsolete */ - ret = 0; - break; } if (ret != -ENOIOCTLCMD) @@ -2413,6 +2392,8 @@ static const struct tty_operations uart_ops = { #endif .tiocmget = uart_tiocmget, .tiocmset = uart_tiocmset, + .set_serial = uart_set_info_user, + .get_serial = uart_get_info_user, .get_icount = uart_get_icount, #ifdef CONFIG_CONSOLE_POLL .poll_init = uart_poll_init, |