Add basic PM Runtime support.
Signed-off-by: Franklin S Cooper Jr <[email protected]>
---
drivers/tty/serial/8250/8250_of.c | 35 ++++++++++++++++++++++++-----------
1 file changed, 24 insertions(+), 11 deletions(-)
diff --git a/drivers/tty/serial/8250/8250_of.c b/drivers/tty/serial/8250/8250_of.c
index 6c5a8ca..94e7c93 100644
--- a/drivers/tty/serial/8250/8250_of.c
+++ b/drivers/tty/serial/8250/8250_of.c
@@ -18,6 +18,7 @@
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_platform.h>
+#include <linux/pm_runtime.h>
#include <linux/clk.h>
#include <linux/reset.h>
@@ -65,6 +66,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
int ret;
memset(port, 0, sizeof *port);
+
+ pm_runtime_enable(&ofdev->dev);
+ pm_runtime_get_sync(&ofdev->dev);
+
if (of_property_read_u32(np, "clock-frequency", &clk)) {
/* Get clk rate through clk driver if present */
@@ -72,12 +77,13 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
if (IS_ERR(info->clk)) {
dev_warn(&ofdev->dev,
"clk or clock-frequency not defined\n");
- return PTR_ERR(info->clk);
+ ret = PTR_ERR(info->clk);
+ goto err_pmruntime;
}
ret = clk_prepare_enable(info->clk);
if (ret < 0)
- return ret;
+ goto err_pmruntime;
clk = clk_get_rate(info->clk);
}
@@ -170,8 +176,10 @@ static int of_platform_serial_setup(struct platform_device *ofdev,
err_dispose:
irq_dispose_mapping(port->irq);
err_unprepare:
- if (info->clk)
- clk_disable_unprepare(info->clk);
+ clk_disable_unprepare(info->clk);
+err_pmruntime:
+ pm_runtime_put_sync(&ofdev->dev);
+ pm_runtime_disable(&ofdev->dev);
return ret;
}
@@ -227,8 +235,9 @@ static int of_platform_serial_probe(struct platform_device *ofdev)
return 0;
err_dispose:
irq_dispose_mapping(port8250.port.irq);
- if (info->clk)
- clk_disable_unprepare(info->clk);
+ pm_runtime_put_sync(&ofdev->dev);
+ pm_runtime_disable(&ofdev->dev);
+ clk_disable_unprepare(info->clk);
err_free:
kfree(info);
return ret;
@@ -244,8 +253,9 @@ static int of_platform_serial_remove(struct platform_device *ofdev)
serial8250_unregister_port(info->line);
reset_control_assert(info->rst);
- if (info->clk)
- clk_disable_unprepare(info->clk);
+ pm_runtime_put_sync(&ofdev->dev);
+ pm_runtime_disable(&ofdev->dev);
+ clk_disable_unprepare(info->clk);
kfree(info);
return 0;
}
@@ -259,9 +269,10 @@ static int of_serial_suspend(struct device *dev)
serial8250_suspend_port(info->line);
- if (info->clk && (!uart_console(port) || console_suspend_enabled))
+ if ((!uart_console(port) || console_suspend_enabled)) {
+ pm_runtime_put_sync(&ofdev->dev);
clk_disable_unprepare(info->clk);
-
+ }
return 0;
}
@@ -271,8 +282,10 @@ static int of_serial_resume(struct device *dev)
struct uart_8250_port *port8250 = serial8250_get_port(info->line);
struct uart_port *port = &port8250->port;
- if (info->clk && (!uart_console(port) || console_suspend_enabled))
+ if ((!uart_console(port) || console_suspend_enabled)) {
+ pm_runtime_get_sync(&ofdev->dev);
clk_prepare_enable(info->clk);
+ }
serial8250_resume_port(info->line);
--
2.9.4.dirty
Hi Franklin,
[auto build test ERROR on tty/tty-testing]
[also build test ERROR on next-20170802]
[cannot apply to v4.13-rc3]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Franklin-S-Cooper-Jr/serial-8250_of-Add-basic-PM-runtime-support/20170803-151414
base: https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git tty-testing
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gnu-gcc (Debian 6.1.1-9) 6.1.1 20160705
reproduce:
wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64
All errors (new ones prefixed by >>):
drivers/tty//serial/8250/8250_of.c: In function 'of_serial_suspend':
>> drivers/tty//serial/8250/8250_of.c:273:24: error: 'ofdev' undeclared (first use in this function)
pm_runtime_put_sync(&ofdev->dev);
^~~~~
drivers/tty//serial/8250/8250_of.c:273:24: note: each undeclared identifier is reported only once for each function it appears in
drivers/tty//serial/8250/8250_of.c: In function 'of_serial_resume':
drivers/tty//serial/8250/8250_of.c:286:24: error: 'ofdev' undeclared (first use in this function)
pm_runtime_get_sync(&ofdev->dev);
^~~~~
vim +/ofdev +273 drivers/tty//serial/8250/8250_of.c
262
263 #ifdef CONFIG_PM_SLEEP
264 static int of_serial_suspend(struct device *dev)
265 {
266 struct of_serial_info *info = dev_get_drvdata(dev);
267 struct uart_8250_port *port8250 = serial8250_get_port(info->line);
268 struct uart_port *port = &port8250->port;
269
270 serial8250_suspend_port(info->line);
271
272 if ((!uart_console(port) || console_suspend_enabled)) {
> 273 pm_runtime_put_sync(&ofdev->dev);
274 clk_disable_unprepare(info->clk);
275 }
276 return 0;
277 }
278
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
On Wed, Aug 02, 2017 at 11:32:18AM -0500, Franklin S Cooper Jr wrote:
> Add basic PM Runtime support.
>
Why? How? For what?
Come on, we need better changelogs than just 5 words...