public inbox for linux-can@vger.kernel.org
 help / color / mirror / Atom feed
From: Patrik Flykt <patrik.flykt@linux.intel.com>
To: linux-can@vger.kernel.org
Cc: wg@grandegger.com, mkl@pengutronix.de, dmurphy@ti.com,
	sriram.dash@samsung.com, jarkko.nikula@intel.com
Subject: [PATCH v2 1/1] NET: mcan: Move runtime PM enable/disable to m_can_platform
Date: Fri, 23 Oct 2020 14:58:00 +0300	[thread overview]
Message-ID: <20201023115800.46538-2-patrik.flykt@linux.intel.com> (raw)
In-Reply-To: <20201023115800.46538-1-patrik.flykt@linux.intel.com>

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 only user, the
m_can_platform driver.

Signed-off-by: Patrik Flykt <patrik.flykt@linux.intel.com>
---
v2: Rebased on mkl/linux-can.git 9146843b11b6

 drivers/net/can/m_can/m_can.c          | 9 ++-------
 drivers/net/can/m_can/m_can_platform.c | 7 ++++++-
 2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/m_can/m_can.c b/drivers/net/can/m_can/m_can.c
index e1d8d1c8ab7d..f81a0761ddad 100644
--- a/drivers/net/can/m_can/m_can.c
+++ b/drivers/net/can/m_can/m_can.c
@@ -1803,10 +1803,9 @@ 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;
+			goto clk_fail;
 	}
 
 	ret = m_can_dev_setup(m_can_dev);
@@ -1832,12 +1831,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);
-	}
 
+clk_fail:
 	return ret;
 }
 EXPORT_SYMBOL_GPL(m_can_class_register);
diff --git a/drivers/net/can/m_can/m_can_platform.c b/drivers/net/can/m_can/m_can_platform.c
index b5b7b77909d3..87264e0f4e94 100644
--- a/drivers/net/can/m_can/m_can_platform.c
+++ b/drivers/net/can/m_can/m_can_platform.c
@@ -134,7 +134,12 @@ static int m_can_plat_probe(struct platform_device *pdev)
 
 	m_can_init_ram(mcan_class);
 
-	return m_can_class_register(mcan_class);
+	pm_runtime_enable(mcan_class->dev);
+	ret = m_can_class_register(mcan_class);
+	if (ret)
+		pm_runtime_disable(mcan_class->dev);
+
+	return ret;
 
 probe_fail:
 	m_can_class_free_dev(mcan_class->net);
-- 
2.28.0


  reply	other threads:[~2020-10-23 11:58 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-23 11:57 [PATCH v2 0/1] NET: mcan: Move runtime PM enable/disable to m_can_platform Patrik Flykt
2020-10-23 11:58 ` Patrik Flykt [this message]
2020-11-17 11:36   ` [PATCH v2 1/1] " Patrik Flykt
2020-11-18 15:47     ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201023115800.46538-2-patrik.flykt@linux.intel.com \
    --to=patrik.flykt@linux.intel.com \
    --cc=dmurphy@ti.com \
    --cc=jarkko.nikula@intel.com \
    --cc=linux-can@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=sriram.dash@samsung.com \
    --cc=wg@grandegger.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox