From: Peter Hurley <peter@hurleysoftware.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Cc: linux-kernel@vger.kernel.org, linux-serial@vger.kernel.org,
Jiri Slaby <jslaby@suse.cz>,
Peter Hurley <peter@hurleysoftware.com>
Subject: [PATCH 1/4] serial: core: Simplify console suspend logic in uart_suspend_port()
Date: Wed, 5 Nov 2014 13:40:51 -0500 [thread overview]
Message-ID: <1415212854-16944-2-git-send-email-peter@hurleysoftware.com> (raw)
In-Reply-To: <1415212854-16944-1-git-send-email-peter@hurleysoftware.com>
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>
---
drivers/tty/serial/serial_core.c | 35 +++++++++++++++++------------------
1 file changed, 17 insertions(+), 18 deletions(-)
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c
index c5fb08c..158e667 100644
--- a/drivers/tty/serial/serial_core.c
+++ b/drivers/tty/serial/serial_core.c
@@ -1959,23 +1959,24 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
}
put_device(tty_dev);
- if (console_suspend_enabled || !uart_console(uport))
- uport->suspended = 1;
+ /* Nothing to do if the console is not suspending */
+ if (!console_suspend_enabled && uart_console(uport))
+ goto unlock;
+
+ uport->suspended = 1;
if (port->flags & ASYNC_INITIALIZED) {
const struct uart_ops *ops = uport->ops;
int tries;
- if (console_suspend_enabled || !uart_console(uport)) {
- set_bit(ASYNCB_SUSPENDED, &port->flags);
- clear_bit(ASYNCB_INITIALIZED, &port->flags);
-
- spin_lock_irq(&uport->lock);
- ops->stop_tx(uport);
- ops->set_mctrl(uport, 0);
- ops->stop_rx(uport);
- spin_unlock_irq(&uport->lock);
- }
+ set_bit(ASYNCB_SUSPENDED, &port->flags);
+ clear_bit(ASYNCB_INITIALIZED, &port->flags);
+
+ spin_lock_irq(&uport->lock);
+ ops->stop_tx(uport);
+ ops->set_mctrl(uport, 0);
+ ops->stop_rx(uport);
+ spin_unlock_irq(&uport->lock);
/*
* Wait for the transmitter to empty.
@@ -1987,19 +1988,17 @@ int uart_suspend_port(struct uart_driver *drv, struct uart_port *uport)
drv->dev_name,
drv->tty_driver->name_base + uport->line);
- if (console_suspend_enabled || !uart_console(uport))
- ops->shutdown(uport);
+ ops->shutdown(uport);
}
/*
* Disable the console device before suspending.
*/
- if (console_suspend_enabled && uart_console(uport))
+ if (uart_console(uport))
console_stop(uport->cons);
- if (console_suspend_enabled || !uart_console(uport))
- uart_change_pm(state, UART_PM_STATE_OFF);
-
+ uart_change_pm(state, UART_PM_STATE_OFF);
+unlock:
mutex_unlock(&port->mutex);
return 0;
--
2.1.3
next prev parent reply other threads:[~2014-11-05 18:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-05 18:40 [PATCH 0/4] fix serial console suspend on PNP Peter Hurley
2014-11-05 18:40 ` Peter Hurley [this message]
2014-11-05 18:40 ` [PATCH 2/4] serial: 8250_pnp: Override pnp disable for no_console_suspend Peter Hurley
2014-11-05 18:40 ` [PATCH 3/4] PNP: Allow device to override ACPI device sleep Peter Hurley
2014-11-05 22:28 ` Rafael J. Wysocki
2014-11-05 22:14 ` Peter Hurley
2014-11-05 18:40 ` [PATCH 4/4] serial: 8250_pnp: Override pnp suspend for no_console_suspend Peter Hurley
2014-11-05 18:45 ` Peter Hurley
2014-11-05 19:02 ` [PATCH v2 " Peter Hurley
2014-11-06 19:06 ` [PATCH 0/4] fix serial console suspend on PNP Greg Kroah-Hartman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1415212854-16944-2-git-send-email-peter@hurleysoftware.com \
--to=peter@hurleysoftware.com \
--cc=gregkh@linuxfoundation.org \
--cc=jslaby@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=rafael.j.wysocki@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).