Commit 46a460f0 authored by Michal Simek's avatar Michal Simek Committed by Greg Kroah-Hartman

serial: uartps: Do not use static struct uart_driver out of probe()

cdns_uart_suspend()/resume() and remove() are using static reference
to struct uart_driver. Assign this reference to private data structure
as preparation step for dynamic struct uart_driver allocation.
Signed-off-by: default avatarMichal Simek <michal.simek@xilinx.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 4b9d33c6
...@@ -180,6 +180,7 @@ MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255"); ...@@ -180,6 +180,7 @@ MODULE_PARM_DESC(rx_timeout, "Rx timeout, 1-255");
* @port: Pointer to the UART port * @port: Pointer to the UART port
* @uartclk: Reference clock * @uartclk: Reference clock
* @pclk: APB clock * @pclk: APB clock
* @cdns_uart_driver: Pointer to UART driver
* @baud: Current baud rate * @baud: Current baud rate
* @clk_rate_change_nb: Notifier block for clock changes * @clk_rate_change_nb: Notifier block for clock changes
* @quirks: Flags for RXBS support. * @quirks: Flags for RXBS support.
...@@ -188,6 +189,7 @@ struct cdns_uart { ...@@ -188,6 +189,7 @@ struct cdns_uart {
struct uart_port *port; struct uart_port *port;
struct clk *uartclk; struct clk *uartclk;
struct clk *pclk; struct clk *pclk;
struct uart_driver *cdns_uart_driver;
unsigned int baud; unsigned int baud;
struct notifier_block clk_rate_change_nb; struct notifier_block clk_rate_change_nb;
u32 quirks; u32 quirks;
...@@ -1273,6 +1275,7 @@ static struct uart_driver cdns_uart_uart_driver = { ...@@ -1273,6 +1275,7 @@ static struct uart_driver cdns_uart_uart_driver = {
static int cdns_uart_suspend(struct device *device) static int cdns_uart_suspend(struct device *device)
{ {
struct uart_port *port = dev_get_drvdata(device); struct uart_port *port = dev_get_drvdata(device);
struct cdns_uart *cdns_uart = port->private_data;
int may_wake; int may_wake;
may_wake = device_may_wakeup(device); may_wake = device_may_wakeup(device);
...@@ -1296,7 +1299,7 @@ static int cdns_uart_suspend(struct device *device) ...@@ -1296,7 +1299,7 @@ static int cdns_uart_suspend(struct device *device)
* Call the API provided in serial_core.c file which handles * Call the API provided in serial_core.c file which handles
* the suspend. * the suspend.
*/ */
return uart_suspend_port(&cdns_uart_uart_driver, port); return uart_suspend_port(cdns_uart->cdns_uart_driver, port);
} }
/** /**
...@@ -1308,6 +1311,7 @@ static int cdns_uart_suspend(struct device *device) ...@@ -1308,6 +1311,7 @@ static int cdns_uart_suspend(struct device *device)
static int cdns_uart_resume(struct device *device) static int cdns_uart_resume(struct device *device)
{ {
struct uart_port *port = dev_get_drvdata(device); struct uart_port *port = dev_get_drvdata(device);
struct cdns_uart *cdns_uart = port->private_data;
unsigned long flags = 0; unsigned long flags = 0;
u32 ctrl_reg; u32 ctrl_reg;
int may_wake; int may_wake;
...@@ -1315,8 +1319,6 @@ static int cdns_uart_resume(struct device *device) ...@@ -1315,8 +1319,6 @@ static int cdns_uart_resume(struct device *device)
may_wake = device_may_wakeup(device); may_wake = device_may_wakeup(device);
if (console_suspend_enabled && !may_wake) { if (console_suspend_enabled && !may_wake) {
struct cdns_uart *cdns_uart = port->private_data;
clk_enable(cdns_uart->pclk); clk_enable(cdns_uart->pclk);
clk_enable(cdns_uart->uartclk); clk_enable(cdns_uart->uartclk);
...@@ -1350,7 +1352,7 @@ static int cdns_uart_resume(struct device *device) ...@@ -1350,7 +1352,7 @@ static int cdns_uart_resume(struct device *device)
spin_unlock_irqrestore(&port->lock, flags); 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 */ #endif /* ! CONFIG_PM_SLEEP */
static int __maybe_unused cdns_runtime_suspend(struct device *dev) static int __maybe_unused cdns_runtime_suspend(struct device *dev)
...@@ -1414,6 +1416,8 @@ static int cdns_uart_probe(struct platform_device *pdev) ...@@ -1414,6 +1416,8 @@ static int cdns_uart_probe(struct platform_device *pdev)
if (!port) if (!port)
return -ENOMEM; return -ENOMEM;
cdns_uart_data->cdns_uart_driver = &cdns_uart_uart_driver;
match = of_match_node(cdns_uart_of_match, pdev->dev.of_node); match = of_match_node(cdns_uart_of_match, pdev->dev.of_node);
if (match && match->data) { if (match && match->data) {
const struct cdns_platform_data *data = match->data; const struct cdns_platform_data *data = match->data;
...@@ -1571,7 +1575,7 @@ static int cdns_uart_remove(struct platform_device *pdev) ...@@ -1571,7 +1575,7 @@ static int cdns_uart_remove(struct platform_device *pdev)
clk_notifier_unregister(cdns_uart_data->uartclk, clk_notifier_unregister(cdns_uart_data->uartclk,
&cdns_uart_data->clk_rate_change_nb); &cdns_uart_data->clk_rate_change_nb);
#endif #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; port->mapbase = 0;
clk_disable_unprepare(cdns_uart_data->uartclk); clk_disable_unprepare(cdns_uart_data->uartclk);
clk_disable_unprepare(cdns_uart_data->pclk); clk_disable_unprepare(cdns_uart_data->pclk);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment