[PATCH 1/1] NET: mcan: Move runtime PM enable/disable to m_can_platform

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a preparatory patch for upcoming PCI based M_CAN devices.
The current PM implementation would cause PCI based drivers to
enable PM twice, once when the pci device is added and a second
time in m_can_class_register(). This will cause 'Unbalanced
pm_runtime_enable!' to be logged, and is a situation that should
be avoided.

Therefore, in anticipation of PCI devices, move PM enabling out
from M_CAN class registration to its currently only user, the
m_can_platform driver.


Signed-off-by: Patrik Flykt <patrik.flykt@xxxxxxxxxxxxxxx>
---
 drivers/net/can/m_can/m_can.c          | 6 +-----
 drivers/net/can/m_can/m_can_platform.c | 3 +++
 2 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index 02c5795b7393..2c4d74113443 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1817,7 +1817,6 @@ int m_can_class_register(struct m_can_classdev *m_can_dev)
 	int ret;
 
 	if (m_can_dev->pm_clock_support) {
-		pm_runtime_enable(m_can_dev->dev);
 		ret = m_can_clk_start(m_can_dev);
 		if (ret)
 			goto pm_runtime_fail;
@@ -1847,11 +1846,8 @@ int m_can_class_register(struct m_can_classdev *m_can_dev)
 clk_disable:
 	m_can_clk_stop(m_can_dev);
 pm_runtime_fail:
-	if (ret) {
-		if (m_can_dev->pm_clock_support)
-			pm_runtime_disable(m_can_dev->dev);
+	if (ret)
 		free_candev(m_can_dev->net);
-	}
 
 	return ret;
 }
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index 38ea5e600fb8..1260e99b9322 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -111,7 +111,10 @@ static int m_can_plat_probe(struct platform_device *pdev)
 
 	m_can_init_ram(mcan_class);
 
+	pm_runtime_enable(mcan_class->dev);
 	ret = m_can_class_register(mcan_class);
+	if (ret)
+		pm_runtime_disable(mcan_class->dev);
 
 failed_ret:
 	return ret;
-- 
2.27.0




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux