Commit f3e8ae65 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

USB: serial: ftdi_sio: simplify TIOCSSERIAL flag logic

Simplify TIOCSSERIAL flag logic somewhat.
Signed-off-by: default avatarJohan Hovold <johan@kernel.org>
Reviewed-by: default avatarAndy Shevchenko <andy.shevchenko@gmail.com>
Reviewed-by: default avatarAlan Cox <alan@linux.intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent dc2f7271
...@@ -1505,8 +1505,7 @@ static int set_serial_info(struct tty_struct *tty, ...@@ -1505,8 +1505,7 @@ static int set_serial_info(struct tty_struct *tty,
/* Do error checking and permission checking */ /* Do error checking and permission checking */
if (!capable(CAP_SYS_ADMIN)) { if (!capable(CAP_SYS_ADMIN)) {
if (((new_serial.flags & ~ASYNC_USR_MASK) != if ((new_serial.flags ^ priv->flags) & ~ASYNC_USR_MASK) {
(priv->flags & ~ASYNC_USR_MASK))) {
mutex_unlock(&priv->cfg_lock); mutex_unlock(&priv->cfg_lock);
return -EPERM; return -EPERM;
} }
...@@ -1530,8 +1529,7 @@ static int set_serial_info(struct tty_struct *tty, ...@@ -1530,8 +1529,7 @@ static int set_serial_info(struct tty_struct *tty,
check_and_exit: check_and_exit:
write_latency_timer(port); write_latency_timer(port);
if ((old_priv.flags & ASYNC_SPD_MASK) != if ((priv->flags ^ old_priv.flags) & ASYNC_SPD_MASK) {
(priv->flags & ASYNC_SPD_MASK)) {
if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
tty->alt_speed = 57600; tty->alt_speed = 57600;
else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
...@@ -1543,10 +1541,9 @@ static int set_serial_info(struct tty_struct *tty, ...@@ -1543,10 +1541,9 @@ static int set_serial_info(struct tty_struct *tty,
else else
tty->alt_speed = 0; tty->alt_speed = 0;
} }
if (((old_priv.flags & ASYNC_SPD_MASK) != if ((priv->flags ^ old_priv.flags) & ASYNC_SPD_MASK ||
(priv->flags & ASYNC_SPD_MASK)) || ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
(((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) && priv->custom_divisor != old_priv.custom_divisor)) {
(old_priv.custom_divisor != priv->custom_divisor))) {
change_speed(tty, port); change_speed(tty, port);
mutex_unlock(&priv->cfg_lock); mutex_unlock(&priv->cfg_lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment