1 From 4e0f5cc65098ea32a1e77baae74215b9bd5276b1 Mon Sep 17 00:00:00 2001
2 From: Tony Lindgren <tony@atomide.com>
3 Date: Fri, 20 Jan 2017 12:22:31 -0800
4 Subject: serial: 8250_omap: Fix probe and remove for PM runtime
6 From: Tony Lindgren <tony@atomide.com>
8 commit 4e0f5cc65098ea32a1e77baae74215b9bd5276b1 upstream.
10 Otherwise the interconnect related code implementing PM runtime will
11 produce these errors on a failed probe:
13 omap_uart 48066000.serial: omap_device: omap_device_enable() called from invalid state 1
14 omap_uart 48066000.serial: use pm_runtime_put_sync_suspend() in driver?
16 Note that we now also need to check for priv in omap8250_runtime_suspend()
17 as it has not yet been registered if probe fails. And we need to use
18 pm_runtime_put_sync() to properly idle the device like we already do
21 Fixes: 61929cf0169d ("tty: serial: Add 8250-core based omap driver")
22 Signed-off-by: Tony Lindgren <tony@atomide.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
26 drivers/tty/serial/8250/8250_omap.c | 8 +++++++-
27 1 file changed, 7 insertions(+), 1 deletion(-)
29 --- a/drivers/tty/serial/8250/8250_omap.c
30 +++ b/drivers/tty/serial/8250/8250_omap.c
31 @@ -1237,7 +1237,8 @@ static int omap8250_probe(struct platfor
32 pm_runtime_put_autosuspend(&pdev->dev);
35 - pm_runtime_put(&pdev->dev);
36 + pm_runtime_dont_use_autosuspend(&pdev->dev);
37 + pm_runtime_put_sync(&pdev->dev);
38 pm_runtime_disable(&pdev->dev);
41 @@ -1246,6 +1247,7 @@ static int omap8250_remove(struct platfo
43 struct omap8250_priv *priv = platform_get_drvdata(pdev);
45 + pm_runtime_dont_use_autosuspend(&pdev->dev);
46 pm_runtime_put_sync(&pdev->dev);
47 pm_runtime_disable(&pdev->dev);
48 serial8250_unregister_port(priv->line);
49 @@ -1345,6 +1347,10 @@ static int omap8250_runtime_suspend(stru
50 struct omap8250_priv *priv = dev_get_drvdata(dev);
51 struct uart_8250_port *up;
53 + /* In case runtime-pm tries this before we are setup */
57 up = serial8250_get_port(priv->line);
59 * When using 'no_console_suspend', the console UART must not be