Skip to contentSkip to conversation

can: m_can: Fix runtime resume call

PATCH Applied Faiz Abbas 2 participants 3 messages Jul 3, 2018 – Jul 23, 2018

Subsystems (4)
lore
Share & tools
lore

Faiz Abbas

author
#0 lore raw

PATCH v2 1/1 can: m_can: Fix runtime resume call

pm_runtime_get_sync() returns a 1 if the state of the device is already 'active'. This is not a failure case and should return a success.

Therefore fix error handling for pm_runtime_get_sync() call such that it returns success when the value is 1.

Also cleanup the TODO for using runtime PM for sleep mode as that is implemented.

---

Changes in v2:

rebased to latest mainline

 drivers/net/can/m_can/m_can.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/can/m_can/m_can.c +4 -4
index b397a33f3d32..ac4c6dc2f8c8 100644
@@ -634,10 +634,12 @@ static int m_can_clk_start(struct m_can_priv *priv)
 	int err;
 
 	err = pm_runtime_get_sync(priv->device);
-	if (err)
+	if (err < 0) {
 		pm_runtime_put_noidle(priv->device);
+		return err;
+	}
 
-	return err;
+	return 0;
 }
 
 static void m_can_clk_stop(struct m_can_priv *priv)
@@ -1687,8 +1689,6 @@ static int m_can_plat_probe(struct platform_device *pdev)
 	return ret;
 }
 
-/* TODO: runtime PM with power down or sleep mode  */
-
 static __maybe_unused int m_can_suspend(struct device *dev)
 {
 	struct net_device *ndev = dev_get_drvdata(dev);
Signature · 1 line
2.17.0
author
#1 lore raw

Hi,

Quoted 40 lines · Faiz Abbas

pm_runtime_get_sync() returns a 1 if the state of the device is already 'active'. This is not a failure case and should return a success.

Therefore fix error handling for pm_runtime_get_sync() call such that it returns success when the value is 1.

Also cleanup the TODO for using runtime PM for sleep mode as that is implemented.

---

Changes in v2:

rebased to latest mainline

 drivers/net/can/m_can/m_can.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/net/can/m_can/m_can.c +4 -2
index b397a33f3d32..ac4c6dc2f8c8 100644
@@ -634,10 +634,12 @@ static int m_can_clk_start(struct m_can_priv *priv)
 	int err;
 
 	err = pm_runtime_get_sync(priv->device);
-	if (err)
+	if (err < 0) {
 		pm_runtime_put_noidle(priv->device);
+		return err;
+	}
 
-	return err;
+	return 0;
 }
 
 static void m_can_clk_stop(struct m_can_priv *priv)

drivers/net/can/m_can/m_can.c static int m_can_plat_probe(struct platform_device *pdev) · line 1694

Quoted 8 lines
drivers/net/can/m_can/m_can.c +0 -2
@@ -1687,8 +1689,6 @@ static int m_can_plat_probe(struct platform_device *pdev)
 	return ret;
 }
 
-/* TODO: runtime PM with power down or sleep mode  */
-
 static __maybe_unused int m_can_suspend(struct device *dev)
 {
 	struct net_device *ndev = dev_get_drvdata(dev);

Gentle ping.

Thanks,
Faiz

maintainer Applied
#2 lore raw
In reply to Faiz Abbas
Quoted 10 lines · Faiz Abbas

pm_runtime_get_sync() returns a 1 if the state of the device is already 'active'. This is not a failure case and should return a success.

Therefore fix error handling for pm_runtime_get_sync() call such that it returns success when the value is 1.

Also cleanup the TODO for using runtime PM for sleep mode as that is implemented.

Applied to linux-can.

Tnx,
Marc

Signature · 4 lines
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |