diff options
author | Jiri Slaby <jslaby@suse.cz> | 2012-03-05 08:52:21 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-03-08 15:30:50 -0500 |
commit | 0f9b9684db2d1369fe303de5729cbdc817265bec (patch) | |
tree | 6a26ef3d46a010d131d6df4948fa455ec4981a68 /drivers/tty/amiserial.c | |
parent | 916b765675b7044bd5895b7430a2aa2c63ea4545 (diff) |
TTY: amiserial, simplify set_serial_info
Do not copy whole serial_state. We only need to know whether the speed
is to be changed. Hence store the info in advance and use it later.
A simple bool is enough.
Also remove reduntant assignments and move the tests directly to the
'if'.
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/amiserial.c')
-rw-r--r-- | drivers/tty/amiserial.c | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/drivers/tty/amiserial.c b/drivers/tty/amiserial.c index 410e8e7e6bfe..165cd79faea2 100644 --- a/drivers/tty/amiserial.c +++ b/drivers/tty/amiserial.c | |||
@@ -1042,21 +1042,19 @@ static int set_serial_info(struct serial_state *state, | |||
1042 | struct serial_struct __user * new_info) | 1042 | struct serial_struct __user * new_info) |
1043 | { | 1043 | { |
1044 | struct serial_struct new_serial; | 1044 | struct serial_struct new_serial; |
1045 | struct serial_state old_state; | 1045 | bool change_spd; |
1046 | unsigned int change_irq,change_port; | ||
1047 | int retval = 0; | 1046 | int retval = 0; |
1048 | 1047 | ||
1049 | if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) | 1048 | if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) |
1050 | return -EFAULT; | 1049 | return -EFAULT; |
1051 | 1050 | ||
1052 | tty_lock(); | 1051 | tty_lock(); |
1053 | old_state = *state; | 1052 | change_spd = ((new_serial.flags ^ state->flags) & ASYNC_SPD_MASK) || |
1054 | 1053 | new_serial.custom_divisor != state->custom_divisor; | |
1055 | change_irq = new_serial.irq != state->irq; | 1054 | if (new_serial.irq != state->irq || new_serial.port != state->port || |
1056 | change_port = (new_serial.port != state->port); | 1055 | new_serial.xmit_fifo_size != state->xmit_fifo_size) { |
1057 | if(change_irq || change_port || (new_serial.xmit_fifo_size != state->xmit_fifo_size)) { | 1056 | tty_unlock(); |
1058 | tty_unlock(); | 1057 | return -EINVAL; |
1059 | return -EINVAL; | ||
1060 | } | 1058 | } |
1061 | 1059 | ||
1062 | if (!serial_isroot()) { | 1060 | if (!serial_isroot()) { |
@@ -1092,9 +1090,7 @@ static int set_serial_info(struct serial_state *state, | |||
1092 | 1090 | ||
1093 | check_and_exit: | 1091 | check_and_exit: |
1094 | if (state->flags & ASYNC_INITIALIZED) { | 1092 | if (state->flags & ASYNC_INITIALIZED) { |
1095 | if (((old_state.flags & ASYNC_SPD_MASK) != | 1093 | if (change_spd) { |
1096 | (state->flags & ASYNC_SPD_MASK)) || | ||
1097 | (old_state.custom_divisor != state->custom_divisor)) { | ||
1098 | if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) | 1094 | if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) |
1099 | state->tty->alt_speed = 57600; | 1095 | state->tty->alt_speed = 57600; |
1100 | if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) | 1096 | if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) |