aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorPeter Hurley <peter@hurleysoftware.com>2015-01-22 12:24:25 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-02-02 13:11:27 -0500
commitb164c9721e3ea4c08a4738cd4d0538bbb0c24419 (patch)
tree7d1705670475dea2d78db62f72f02f1708a03576 /drivers/tty
parentea9e9d8029020d438b0717ffddf65140fda16051 (diff)
serial: core: Simplify console suspend logic in uart_suspend_port()
When the uart port being suspended is a console and consoles are not suspending (kernel command line contains no_console_suspend), then no action is performed for that port, and the function can return early. If the function has not returned early, then one of the conditions is not true, so the expression (console_suspend_enabled || !uart_console(uport)) must be true and can be eliminated. Similarly, the expression (console_suspend_enabled && uart_console(uport)) simplifies to just uart_console(uport). Signed-off-by: Peter Hurley <peter@hurleysoftware.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/serial_core.c35
1 files changed, 17 insertions, 18 deletions
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index 984605bb5bf1..2c67a077042a 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -2008,23 +2008,24 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
2008 } 2008 }
2009 put_device(tty_dev); 2009 put_device(tty_dev);
2010 2010
2011 if (console_suspend_enabled || !uart_console(uport)) 2011 /* Nothing to do if the console is not suspending */
2012 uport->suspended = 1; 2012 if (!console_suspend_enabled && uart_console(uport))
2013 goto unlock;
2014
2015 uport->suspended = 1;
2013 2016
2014 if (port->flags & ASYNC_INITIALIZED) { 2017 if (port->flags & ASYNC_INITIALIZED) {
2015 const struct uart_ops *ops = uport->ops; 2018 const struct uart_ops *ops = uport->ops;
2016 int tries; 2019 int tries;
2017 2020
2018 if (console_suspend_enabled || !uart_console(uport)) { 2021 set_bit(ASYNCB_SUSPENDED, &port->flags);
2019 set_bit(ASYNCB_SUSPENDED, &port->flags); 2022 clear_bit(ASYNCB_INITIALIZED, &port->flags);
2020 clear_bit(ASYNCB_INITIALIZED, &port->flags); 2023
2021 2024 spin_lock_irq(&uport->lock);
2022 spin_lock_irq(&uport->lock); 2025 ops->stop_tx(uport);
2023 ops->stop_tx(uport); 2026 ops->set_mctrl(uport, 0);
2024 ops->set_mctrl(uport, 0); 2027 ops->stop_rx(uport);
2025 ops->stop_rx(uport); 2028 spin_unlock_irq(&uport->lock);
2026 spin_unlock_irq(&uport->lock);
2027 }
2028 2029
2029 /* 2030 /*
2030 * Wait for the transmitter to empty. 2031 * Wait for the transmitter to empty.
@@ -2036,19 +2037,17 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
2036 drv->dev_name, 2037 drv->dev_name,
2037 drv->tty_driver->name_base + uport->line); 2038 drv->tty_driver->name_base + uport->line);
2038 2039
2039 if (console_suspend_enabled || !uart_console(uport)) 2040 ops->shutdown(uport);
2040 ops->shutdown(uport);
2041 } 2041 }
2042 2042
2043 /* 2043 /*
2044 * Disable the console device before suspending. 2044 * Disable the console device before suspending.
2045 */ 2045 */
2046 if (console_suspend_enabled && uart_console(uport)) 2046 if (uart_console(uport))
2047 console_stop(uport->cons); 2047 console_stop(uport->cons);
2048 2048
2049 if (console_suspend_enabled || !uart_console(uport)) 2049 uart_change_pm(state, UART_PM_STATE_OFF);
2050 uart_change_pm(state, UART_PM_STATE_OFF); 2050unlock:
2051
2052 mutex_unlock(&port->mutex); 2051 mutex_unlock(&port->mutex);
2053 2052
2054 return 0; 2053 return 0;