Commit 0f9b9684 authored by Jiri Slaby's avatar Jiri Slaby Committed by Greg Kroah-Hartman

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: default avatarJiri Slaby <jslaby@suse.cz>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 916b7656
...@@ -1042,21 +1042,19 @@ static int set_serial_info(struct serial_state *state, ...@@ -1042,21 +1042,19 @@ static int set_serial_info(struct serial_state *state,
struct serial_struct __user * new_info) struct serial_struct __user * new_info)
{ {
struct serial_struct new_serial; struct serial_struct new_serial;
struct serial_state old_state; bool change_spd;
unsigned int change_irq,change_port;
int retval = 0; int retval = 0;
if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) if (copy_from_user(&new_serial,new_info,sizeof(new_serial)))
return -EFAULT; return -EFAULT;
tty_lock(); tty_lock();
old_state = *state; change_spd = ((new_serial.flags ^ state->flags) & ASYNC_SPD_MASK) ||
new_serial.custom_divisor != state->custom_divisor;
change_irq = new_serial.irq != state->irq; if (new_serial.irq != state->irq || new_serial.port != state->port ||
change_port = (new_serial.port != state->port); new_serial.xmit_fifo_size != state->xmit_fifo_size) {
if(change_irq || change_port || (new_serial.xmit_fifo_size != state->xmit_fifo_size)) { tty_unlock();
tty_unlock(); return -EINVAL;
return -EINVAL;
} }
if (!serial_isroot()) { if (!serial_isroot()) {
...@@ -1092,9 +1090,7 @@ static int set_serial_info(struct serial_state *state, ...@@ -1092,9 +1090,7 @@ static int set_serial_info(struct serial_state *state,
check_and_exit: check_and_exit:
if (state->flags & ASYNC_INITIALIZED) { if (state->flags & ASYNC_INITIALIZED) {
if (((old_state.flags & ASYNC_SPD_MASK) != if (change_spd) {
(state->flags & ASYNC_SPD_MASK)) ||
(old_state.custom_divisor != state->custom_divisor)) {
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
state->tty->alt_speed = 57600; state->tty->alt_speed = 57600;
if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) if ((state->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
......
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