USB: serial: cp210x: fix flow-control error handling
Make sure that the driver crtscts state is not updated in the unlikely
event that the flow-control request fails. Not doing so could break RTS
control.
Fixes: 5951b85088
("USB: serial: cp210x: suppress modem-control errors")
Cc: stable@vger.kernel.org # 5.11
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Johan Hovold <johan@kernel.org>
This commit is contained in:
Родитель
2d9a007059
Коммит
ba4bbdabec
|
@ -1190,6 +1190,7 @@ static void cp210x_set_flow_control(struct tty_struct *tty,
|
||||||
struct cp210x_flow_ctl flow_ctl;
|
struct cp210x_flow_ctl flow_ctl;
|
||||||
u32 flow_repl;
|
u32 flow_repl;
|
||||||
u32 ctl_hs;
|
u32 ctl_hs;
|
||||||
|
bool crtscts;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1249,14 +1250,14 @@ static void cp210x_set_flow_control(struct tty_struct *tty,
|
||||||
flow_repl |= CP210X_SERIAL_RTS_FLOW_CTL;
|
flow_repl |= CP210X_SERIAL_RTS_FLOW_CTL;
|
||||||
else
|
else
|
||||||
flow_repl |= CP210X_SERIAL_RTS_INACTIVE;
|
flow_repl |= CP210X_SERIAL_RTS_INACTIVE;
|
||||||
port_priv->crtscts = true;
|
crtscts = true;
|
||||||
} else {
|
} else {
|
||||||
ctl_hs &= ~CP210X_SERIAL_CTS_HANDSHAKE;
|
ctl_hs &= ~CP210X_SERIAL_CTS_HANDSHAKE;
|
||||||
if (port_priv->rts)
|
if (port_priv->rts)
|
||||||
flow_repl |= CP210X_SERIAL_RTS_ACTIVE;
|
flow_repl |= CP210X_SERIAL_RTS_ACTIVE;
|
||||||
else
|
else
|
||||||
flow_repl |= CP210X_SERIAL_RTS_INACTIVE;
|
flow_repl |= CP210X_SERIAL_RTS_INACTIVE;
|
||||||
port_priv->crtscts = false;
|
crtscts = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (I_IXOFF(tty)) {
|
if (I_IXOFF(tty)) {
|
||||||
|
@ -1279,8 +1280,12 @@ static void cp210x_set_flow_control(struct tty_struct *tty,
|
||||||
flow_ctl.ulControlHandshake = cpu_to_le32(ctl_hs);
|
flow_ctl.ulControlHandshake = cpu_to_le32(ctl_hs);
|
||||||
flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl);
|
flow_ctl.ulFlowReplace = cpu_to_le32(flow_repl);
|
||||||
|
|
||||||
cp210x_write_reg_block(port, CP210X_SET_FLOW, &flow_ctl,
|
ret = cp210x_write_reg_block(port, CP210X_SET_FLOW, &flow_ctl,
|
||||||
sizeof(flow_ctl));
|
sizeof(flow_ctl));
|
||||||
|
if (ret)
|
||||||
|
goto out_unlock;
|
||||||
|
|
||||||
|
port_priv->crtscts = crtscts;
|
||||||
out_unlock:
|
out_unlock:
|
||||||
mutex_unlock(&port_priv->mutex);
|
mutex_unlock(&port_priv->mutex);
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче