tty: mxser: fix TIOCSSERIAL jiffies conversions
The port close_delay and closing wait parameters set by TIOCSSERIAL are specified in jiffies, while the values returned by TIOCGSERIAL are specified in centiseconds. Add the missing conversions so that TIOCSSERIAL works as expected also when HZ is not 100. Cc: stable@vger.kernel.org Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://lore.kernel.org/r/20210407102334.32361-14-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
bf510acbea
commit
be6cf583d2
|
@ -1208,19 +1208,26 @@ static int mxser_get_serial_info(struct tty_struct *tty,
|
|||
{
|
||||
struct mxser_port *info = tty->driver_data;
|
||||
struct tty_port *port = &info->port;
|
||||
unsigned int closing_wait, close_delay;
|
||||
|
||||
if (tty->index == MXSER_PORTS)
|
||||
return -ENOTTY;
|
||||
|
||||
mutex_lock(&port->mutex);
|
||||
|
||||
close_delay = jiffies_to_msecs(info->port.close_delay) / 10;
|
||||
closing_wait = info->port.closing_wait;
|
||||
if (closing_wait != ASYNC_CLOSING_WAIT_NONE)
|
||||
closing_wait = jiffies_to_msecs(closing_wait) / 10;
|
||||
|
||||
ss->type = info->type,
|
||||
ss->line = tty->index,
|
||||
ss->port = info->ioaddr,
|
||||
ss->irq = info->board->irq,
|
||||
ss->flags = info->port.flags,
|
||||
ss->baud_base = info->baud_base,
|
||||
ss->close_delay = info->port.close_delay,
|
||||
ss->closing_wait = info->port.closing_wait,
|
||||
ss->close_delay = close_delay;
|
||||
ss->closing_wait = closing_wait;
|
||||
ss->custom_divisor = info->custom_divisor,
|
||||
mutex_unlock(&port->mutex);
|
||||
return 0;
|
||||
|
@ -1233,7 +1240,7 @@ static int mxser_set_serial_info(struct tty_struct *tty,
|
|||
struct tty_port *port = &info->port;
|
||||
speed_t baud;
|
||||
unsigned long sl_flags;
|
||||
unsigned int flags;
|
||||
unsigned int flags, close_delay, closing_wait;
|
||||
int retval = 0;
|
||||
|
||||
if (tty->index == MXSER_PORTS)
|
||||
|
@ -1255,9 +1262,14 @@ static int mxser_set_serial_info(struct tty_struct *tty,
|
|||
|
||||
flags = port->flags & ASYNC_SPD_MASK;
|
||||
|
||||
close_delay = msecs_to_jiffies(ss->close_delay * 10);
|
||||
closing_wait = ss->closing_wait;
|
||||
if (closing_wait != ASYNC_CLOSING_WAIT_NONE)
|
||||
closing_wait = msecs_to_jiffies(closing_wait * 10);
|
||||
|
||||
if (!capable(CAP_SYS_ADMIN)) {
|
||||
if ((ss->baud_base != info->baud_base) ||
|
||||
(ss->close_delay != info->port.close_delay) ||
|
||||
(close_delay != info->port.close_delay) ||
|
||||
((ss->flags & ~ASYNC_USR_MASK) != (info->port.flags & ~ASYNC_USR_MASK))) {
|
||||
mutex_unlock(&port->mutex);
|
||||
return -EPERM;
|
||||
|
@ -1271,8 +1283,8 @@ static int mxser_set_serial_info(struct tty_struct *tty,
|
|||
*/
|
||||
port->flags = ((port->flags & ~ASYNC_FLAGS) |
|
||||
(ss->flags & ASYNC_FLAGS));
|
||||
port->close_delay = ss->close_delay * HZ / 100;
|
||||
port->closing_wait = ss->closing_wait * HZ / 100;
|
||||
port->close_delay = close_delay;
|
||||
port->closing_wait = closing_wait;
|
||||
if ((port->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
|
||||
(ss->baud_base != info->baud_base ||
|
||||
ss->custom_divisor !=
|
||||
|
|
Loading…
Reference in New Issue