mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-05 10:31:46 +09:00
serial: Move uart_change_speed() earlier
[ Upstream commit8e90cf29ae] Move uart_change_speed() earlier to get rid of its forward declaration. Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com> Link: https://lore.kernel.org/r/20230309080923.11778-5-ilpo.jarvinen@linux.intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Stable-dep-of:8679328eb8("serial: Reduce spinlocked portion of uart_rs485_config()") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
4d382ba65d
commit
e4df8000bd
@@ -48,8 +48,6 @@ static struct lock_class_key port_lock_key;
|
|||||||
*/
|
*/
|
||||||
#define RS485_MAX_RTS_DELAY 100 /* msecs */
|
#define RS485_MAX_RTS_DELAY 100 /* msecs */
|
||||||
|
|
||||||
static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
|
|
||||||
const struct ktermios *old_termios);
|
|
||||||
static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
|
static void uart_wait_until_sent(struct tty_struct *tty, int timeout);
|
||||||
static void uart_change_pm(struct uart_state *state,
|
static void uart_change_pm(struct uart_state *state,
|
||||||
enum uart_pm_state pm_state);
|
enum uart_pm_state pm_state);
|
||||||
@@ -177,6 +175,52 @@ static void uart_port_dtr_rts(struct uart_port *uport, int raise)
|
|||||||
uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
|
uart_clear_mctrl(uport, TIOCM_DTR | TIOCM_RTS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Caller holds port mutex */
|
||||||
|
static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
|
||||||
|
const struct ktermios *old_termios)
|
||||||
|
{
|
||||||
|
struct uart_port *uport = uart_port_check(state);
|
||||||
|
struct ktermios *termios;
|
||||||
|
int hw_stopped;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If we have no tty, termios, or the port does not exist,
|
||||||
|
* then we can't set the parameters for this port.
|
||||||
|
*/
|
||||||
|
if (!tty || uport->type == PORT_UNKNOWN)
|
||||||
|
return;
|
||||||
|
|
||||||
|
termios = &tty->termios;
|
||||||
|
uport->ops->set_termios(uport, termios, old_termios);
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Set modem status enables based on termios cflag
|
||||||
|
*/
|
||||||
|
spin_lock_irq(&uport->lock);
|
||||||
|
if (termios->c_cflag & CRTSCTS)
|
||||||
|
uport->status |= UPSTAT_CTS_ENABLE;
|
||||||
|
else
|
||||||
|
uport->status &= ~UPSTAT_CTS_ENABLE;
|
||||||
|
|
||||||
|
if (termios->c_cflag & CLOCAL)
|
||||||
|
uport->status &= ~UPSTAT_DCD_ENABLE;
|
||||||
|
else
|
||||||
|
uport->status |= UPSTAT_DCD_ENABLE;
|
||||||
|
|
||||||
|
/* reset sw-assisted CTS flow control based on (possibly) new mode */
|
||||||
|
hw_stopped = uport->hw_stopped;
|
||||||
|
uport->hw_stopped = uart_softcts_mode(uport) &&
|
||||||
|
!(uport->ops->get_mctrl(uport) & TIOCM_CTS);
|
||||||
|
if (uport->hw_stopped) {
|
||||||
|
if (!hw_stopped)
|
||||||
|
uport->ops->stop_tx(uport);
|
||||||
|
} else {
|
||||||
|
if (hw_stopped)
|
||||||
|
__uart_start(tty);
|
||||||
|
}
|
||||||
|
spin_unlock_irq(&uport->lock);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Startup the port. This will be called once per open. All calls
|
* Startup the port. This will be called once per open. All calls
|
||||||
* will be serialised by the per-port mutex.
|
* will be serialised by the per-port mutex.
|
||||||
@@ -485,52 +529,6 @@ uart_get_divisor(struct uart_port *port, unsigned int baud)
|
|||||||
}
|
}
|
||||||
EXPORT_SYMBOL(uart_get_divisor);
|
EXPORT_SYMBOL(uart_get_divisor);
|
||||||
|
|
||||||
/* Caller holds port mutex */
|
|
||||||
static void uart_change_speed(struct tty_struct *tty, struct uart_state *state,
|
|
||||||
const struct ktermios *old_termios)
|
|
||||||
{
|
|
||||||
struct uart_port *uport = uart_port_check(state);
|
|
||||||
struct ktermios *termios;
|
|
||||||
int hw_stopped;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* If we have no tty, termios, or the port does not exist,
|
|
||||||
* then we can't set the parameters for this port.
|
|
||||||
*/
|
|
||||||
if (!tty || uport->type == PORT_UNKNOWN)
|
|
||||||
return;
|
|
||||||
|
|
||||||
termios = &tty->termios;
|
|
||||||
uport->ops->set_termios(uport, termios, old_termios);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Set modem status enables based on termios cflag
|
|
||||||
*/
|
|
||||||
spin_lock_irq(&uport->lock);
|
|
||||||
if (termios->c_cflag & CRTSCTS)
|
|
||||||
uport->status |= UPSTAT_CTS_ENABLE;
|
|
||||||
else
|
|
||||||
uport->status &= ~UPSTAT_CTS_ENABLE;
|
|
||||||
|
|
||||||
if (termios->c_cflag & CLOCAL)
|
|
||||||
uport->status &= ~UPSTAT_DCD_ENABLE;
|
|
||||||
else
|
|
||||||
uport->status |= UPSTAT_DCD_ENABLE;
|
|
||||||
|
|
||||||
/* reset sw-assisted CTS flow control based on (possibly) new mode */
|
|
||||||
hw_stopped = uport->hw_stopped;
|
|
||||||
uport->hw_stopped = uart_softcts_mode(uport) &&
|
|
||||||
!(uport->ops->get_mctrl(uport) & TIOCM_CTS);
|
|
||||||
if (uport->hw_stopped) {
|
|
||||||
if (!hw_stopped)
|
|
||||||
uport->ops->stop_tx(uport);
|
|
||||||
} else {
|
|
||||||
if (hw_stopped)
|
|
||||||
__uart_start(tty);
|
|
||||||
}
|
|
||||||
spin_unlock_irq(&uport->lock);
|
|
||||||
}
|
|
||||||
|
|
||||||
static int uart_put_char(struct tty_struct *tty, unsigned char c)
|
static int uart_put_char(struct tty_struct *tty, unsigned char c)
|
||||||
{
|
{
|
||||||
struct uart_state *state = tty->driver_data;
|
struct uart_state *state = tty->driver_data;
|
||||||
|
|||||||
Reference in New Issue
Block a user