cdns_uart_suspend()/resume() and remove() are using static reference
to struct uart_driver. Assign this referece to private data structure
as preparation step for dynamic struct uart_driver allocation.

Signed-off-by: Michal Simek <michal.si...@xilinx.com>
---

Changes in v2:
- new patch - it can be sent separately too

 drivers/tty/serial/xilinx_uartps.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/tty/serial/xilinx_uartps.c 
b/drivers/tty/serial/xilinx_uartps.c
index e24382f58dea..fe96fd950d3a 100644
--- a/drivers/tty/serial/xilinx_uartps.c
+++ b/drivers/tty/serial/xilinx_uartps.c
@@ -179,6 +179,7 @@
  * @port:              Pointer to the UART port
  * @uartclk:           Reference clock
  * @pclk:              APB clock
+ * @cdns_uart_driver:  Pointer to UART driver
  * @baud:              Current baud rate
  * @clk_rate_change_nb:        Notifier block for clock changes
  * @quirks:            Flags for RXBS support.
@@ -187,6 +188,7 @@ struct cdns_uart {
        struct uart_port        *port;
        struct clk              *uartclk;
        struct clk              *pclk;
+       struct uart_driver      *cdns_uart_driver;
        unsigned int            baud;
        struct notifier_block   clk_rate_change_nb;
        u32                     quirks;
@@ -1280,6 +1282,7 @@ static int __init cdns_uart_console_setup(struct console 
*co, char *options)
 static int cdns_uart_suspend(struct device *device)
 {
        struct uart_port *port = dev_get_drvdata(device);
+       struct cdns_uart *cdns_uart = port->private_data;
        struct tty_struct *tty;
        struct device *tty_dev;
        int may_wake = 0;
@@ -1296,7 +1299,7 @@ static int cdns_uart_suspend(struct device *device)
         * Call the API provided in serial_core.c file which handles
         * the suspend.
         */
-       uart_suspend_port(&cdns_uart_uart_driver, port);
+       uart_suspend_port(cdns_uart->cdns_uart_driver, port);
        if (!(console_suspend_enabled && !may_wake)) {
                unsigned long flags = 0;
 
@@ -1324,6 +1327,7 @@ static int cdns_uart_suspend(struct device *device)
 static int cdns_uart_resume(struct device *device)
 {
        struct uart_port *port = dev_get_drvdata(device);
+       struct cdns_uart *cdns_uart = port->private_data;
        unsigned long flags = 0;
        u32 ctrl_reg;
        struct tty_struct *tty;
@@ -1339,8 +1343,6 @@ static int cdns_uart_resume(struct device *device)
        }
 
        if (console_suspend_enabled && !may_wake) {
-               struct cdns_uart *cdns_uart = port->private_data;
-
                clk_enable(cdns_uart->pclk);
                clk_enable(cdns_uart->uartclk);
 
@@ -1374,7 +1376,7 @@ static int cdns_uart_resume(struct device *device)
                spin_unlock_irqrestore(&port->lock, flags);
        }
 
-       return uart_resume_port(&cdns_uart_uart_driver, port);
+       return uart_resume_port(cdns_uart->cdns_uart_driver, port);
 }
 #endif /* ! CONFIG_PM_SLEEP */
 static int __maybe_unused cdns_runtime_suspend(struct device *dev)
@@ -1446,6 +1448,8 @@ static int cdns_uart_probe(struct platform_device *pdev)
                }
        }
 
+       cdns_uart_data->cdns_uart_driver = &cdns_uart_uart_driver;
+
        match = of_match_node(cdns_uart_of_match, pdev->dev.of_node);
        if (match && match->data) {
                const struct cdns_platform_data *data = match->data;
@@ -1603,7 +1607,7 @@ static int cdns_uart_remove(struct platform_device *pdev)
        clk_notifier_unregister(cdns_uart_data->uartclk,
                        &cdns_uart_data->clk_rate_change_nb);
 #endif
-       rc = uart_remove_one_port(&cdns_uart_uart_driver, port);
+       rc = uart_remove_one_port(cdns_uart_data->cdns_uart_driver, port);
        port->mapbase = 0;
        clk_disable_unprepare(cdns_uart_data->uartclk);
        clk_disable_unprepare(cdns_uart_data->pclk);
-- 
1.9.1

Reply via email to