Skip to content

Commit

Permalink
USB: serial: ftdi_sio: simplify TIOCSSERIAL flag logic
Browse files Browse the repository at this point in the history
Simplify TIOCSSERIAL flag logic somewhat.

Signed-off-by: Johan Hovold <[email protected]>
Reviewed-by: Andy Shevchenko <[email protected]>
Reviewed-by: Alan Cox <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
jhovold authored and gregkh committed Jun 13, 2017
1 parent dc2f727 commit f3e8ae6
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions drivers/usb/serial/ftdi_sio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1505,8 +1505,7 @@ static int set_serial_info(struct tty_struct *tty,
/* Do error checking and permission checking */

if (!capable(CAP_SYS_ADMIN)) {
if (((new_serial.flags & ~ASYNC_USR_MASK) !=
(priv->flags & ~ASYNC_USR_MASK))) {
if ((new_serial.flags ^ priv->flags) & ~ASYNC_USR_MASK) {
mutex_unlock(&priv->cfg_lock);
return -EPERM;
}
Expand All @@ -1530,8 +1529,7 @@ static int set_serial_info(struct tty_struct *tty,
check_and_exit:
write_latency_timer(port);

if ((old_priv.flags & ASYNC_SPD_MASK) !=
(priv->flags & ASYNC_SPD_MASK)) {
if ((priv->flags ^ old_priv.flags) & ASYNC_SPD_MASK) {
if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
tty->alt_speed = 57600;
else if ((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
Expand All @@ -1543,10 +1541,9 @@ static int set_serial_info(struct tty_struct *tty,
else
tty->alt_speed = 0;
}
if (((old_priv.flags & ASYNC_SPD_MASK) !=
(priv->flags & ASYNC_SPD_MASK)) ||
(((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST) &&
(old_priv.custom_divisor != priv->custom_divisor))) {
if ((priv->flags ^ old_priv.flags) & ASYNC_SPD_MASK ||
((priv->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST &&
priv->custom_divisor != old_priv.custom_divisor)) {
change_speed(tty, port);
mutex_unlock(&priv->cfg_lock);
}
Expand Down

0 comments on commit f3e8ae6

Please sign in to comment.