diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2018-09-12 03:59:13 +0200 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2018-10-13 06:50:06 +0200 |
commit | b129cbc99b2d09a4c4c5de60f91118ecb380e2fa (patch) | |
tree | 116c52c668d314da8e5805ac0197aad705faa355 /drivers/tty/amiserial.c | |
parent | greybus/uart: switch to ->[sg]et_serial() (diff) | |
download | linux-b129cbc99b2d09a4c4c5de60f91118ecb380e2fa.tar.xz linux-b129cbc99b2d09a4c4c5de60f91118ecb380e2fa.zip |
amiserial: switch to ->[sg]et_serial()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'drivers/tty/amiserial.c')
-rw-r--r-- | drivers/tty/amiserial.c | 78 |
1 files changed, 33 insertions, 45 deletions
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 34dead614149..51cfe4f1afcf 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c @@ -996,63 +996,55 @@ static void rs_unthrottle(struct tty_struct * tty) * ------------------------------------------------------------ */ -static int get_serial_info(struct tty_struct *tty, struct serial_state *state, - struct serial_struct __user * retinfo) +static int get_serial_info(struct tty_struct *tty, struct serial_struct *ss) { - struct serial_struct tmp; - - memset(&tmp, 0, sizeof(tmp)); + struct serial_state *state = tty->driver_data; + tty_lock(tty); - tmp.line = tty->index; - tmp.port = state->port; - tmp.flags = state->tport.flags; - tmp.xmit_fifo_size = state->xmit_fifo_size; - tmp.baud_base = state->baud_base; - tmp.close_delay = state->tport.close_delay; - tmp.closing_wait = state->tport.closing_wait; - tmp.custom_divisor = state->custom_divisor; + ss->line = tty->index; + ss->port = state->port; + ss->flags = state->tport.flags; + ss->xmit_fifo_size = state->xmit_fifo_size; + ss->baud_base = state->baud_base; + ss->close_delay = state->tport.close_delay; + ss->closing_wait = state->tport.closing_wait; + ss->custom_divisor = state->custom_divisor; tty_unlock(tty); - if (copy_to_user(retinfo,&tmp,sizeof(*retinfo))) - return -EFAULT; return 0; } -static int set_serial_info(struct tty_struct *tty, struct serial_state *state, - struct serial_struct __user * new_info) +static int set_serial_info(struct tty_struct *tty, struct serial_struct *ss) { + struct serial_state *state = tty->driver_data; struct tty_port *port = &state->tport; - struct serial_struct new_serial; bool change_spd; int retval = 0; - if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) - return -EFAULT; - tty_lock(tty); - change_spd = ((new_serial.flags ^ port->flags) & ASYNC_SPD_MASK) || - new_serial.custom_divisor != state->custom_divisor; - if (new_serial.irq || new_serial.port != state->port || - new_serial.xmit_fifo_size != state->xmit_fifo_size) { + change_spd = ((ss->flags ^ port->flags) & ASYNC_SPD_MASK) || + ss->custom_divisor != state->custom_divisor; + if (ss->irq || ss->port != state->port || + ss->xmit_fifo_size != state->xmit_fifo_size) { tty_unlock(tty); return -EINVAL; } if (!serial_isroot()) { - if ((new_serial.baud_base != state->baud_base) || - (new_serial.close_delay != port->close_delay) || - (new_serial.xmit_fifo_size != state->xmit_fifo_size) || - ((new_serial.flags & ~ASYNC_USR_MASK) != + if ((ss->baud_base != state->baud_base) || + (ss->close_delay != port->close_delay) || + (ss->xmit_fifo_size != state->xmit_fifo_size) || + ((ss->flags & ~ASYNC_USR_MASK) != (port->flags & ~ASYNC_USR_MASK))) { tty_unlock(tty); return -EPERM; } port->flags = ((port->flags & ~ASYNC_USR_MASK) | - (new_serial.flags & ASYNC_USR_MASK)); - state->custom_divisor = new_serial.custom_divisor; + (ss->flags & ASYNC_USR_MASK)); + state->custom_divisor = ss->custom_divisor; goto check_and_exit; } - if (new_serial.baud_base < 9600) { + if (ss->baud_base < 9600) { tty_unlock(tty); return -EINVAL; } @@ -1062,19 +1054,19 @@ static int set_serial_info(struct tty_struct *tty, struct serial_state *state, * At this point, we start making changes..... */ - state->baud_base = new_serial.baud_base; + state->baud_base = ss->baud_base; port->flags = ((port->flags & ~ASYNC_FLAGS) | - (new_serial.flags & ASYNC_FLAGS)); - state->custom_divisor = new_serial.custom_divisor; - port->close_delay = new_serial.close_delay * HZ/100; - port->closing_wait = new_serial.closing_wait * HZ/100; + (ss->flags & ASYNC_FLAGS)); + state->custom_divisor = ss->custom_divisor; + port->close_delay = ss->close_delay * HZ/100; + port->closing_wait = ss->closing_wait * HZ/100; port->low_latency = (port->flags & ASYNC_LOW_LATENCY) ? 1 : 0; check_and_exit: if (tty_port_initialized(port)) { if (change_spd) { /* warn about deprecation unless clearing */ - if (new_serial.flags & ASYNC_SPD_MASK) + if (ss->flags & ASYNC_SPD_MASK) dev_warn_ratelimited(tty->dev, "use of SPD flags is deprecated\n"); change_speed(tty, state, NULL); } @@ -1084,7 +1076,6 @@ check_and_exit: return retval; } - /* * get_lsr_info - get line status register info * @@ -1224,18 +1215,13 @@ static int rs_ioctl(struct tty_struct *tty, if (serial_paranoia_check(info, tty->name, "rs_ioctl")) return -ENODEV; - if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) && - (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) && + if ((cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) && (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) { if (tty_io_error(tty)) return -EIO; } switch (cmd) { - case TIOCGSERIAL: - return get_serial_info(tty, info, argp); - case TIOCSSERIAL: - return set_serial_info(tty, info, argp); case TIOCSERCONFIG: return 0; @@ -1607,6 +1593,8 @@ static const struct tty_operations serial_ops = { .tiocmget = rs_tiocmget, .tiocmset = rs_tiocmset, .get_icount = rs_get_icount, + .set_serial = set_serial_info, + .get_serial = get_serial_info, .proc_show = rs_proc_show, }; |