[PATCH 6/8] serial: imx: add a flag to indicate we are in the suspend path

From: Eduardo Valentin
Date: Sun Aug 09 2015 - 14:19:42 EST


This is a simple flag that gets set across prepare and complete
callbacks in the suspend path. We the flag we may avoid
runtime pm idling at the same time.

Cc: Fabio Stevam <festevam@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
Cc: Jiri Slaby <jslaby@xxxxxxxx>
Cc: linux-serial@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
Signed-off-by: Eduardo Valentin <edubezval@xxxxxxxxx>
---
drivers/tty/serial/imx.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)

diff --git a/drivers/tty/serial/imx.c b/drivers/tty/serial/imx.c
index 494b182..def52e0 100644
--- a/drivers/tty/serial/imx.c
+++ b/drivers/tty/serial/imx.c
@@ -219,6 +219,8 @@ struct imx_port {
wait_queue_head_t dma_wait;
unsigned int saved_reg[8];
bool context_saved;
+
+ bool is_suspending;
};

struct imx_port_ucrs {
@@ -1805,6 +1807,22 @@ static struct uart_driver imx_reg = {
.cons = IMX_CONSOLE,
};

+static int serial_imx_prepare(struct device *dev)
+{
+ struct imx_port *sport = dev_get_drvdata(dev);
+
+ sport->is_suspending = true;
+
+ return 0;
+}
+
+static void serial_imx_complete(struct device *dev)
+{
+ struct imx_port *sport = dev_get_drvdata(dev);
+
+ sport->is_suspending = false;
+}
+
static void serial_imx_restore_context(struct imx_port *sport)
{
if (!sport->context_saved)
@@ -2033,6 +2051,8 @@ static int serial_imx_remove(struct platform_device *pdev)

static const struct dev_pm_ops serial_imx_dev_pm_ops = {
SET_SYSTEM_SLEEP_PM_OPS(serial_imx_suspend, serial_imx_resume)
+ .prepare = serial_imx_prepare,
+ .complete = serial_imx_complete,
};

static struct platform_driver serial_imx_driver = {
--
2.5.0

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/