netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] can: rcar_can: Fix suspend/resume
@ 2021-09-21  5:19 Yoshihiro Shimoda
  2021-09-21 10:38 ` Ulrich Hecht
  2021-09-23 13:30 ` Biju Das
  0 siblings, 2 replies; 5+ messages in thread
From: Yoshihiro Shimoda @ 2021-09-21  5:19 UTC (permalink / raw)
  To: wg, mkl
  Cc: davem, kuba, linux-can, netdev, linux-renesas-soc,
	Yoshihiro Shimoda, Ayumi Nakamichi

If the driver was not opened, rcar_can_suspend() should not call
clk_disable() because the clock was not enabled.

Fixes: fd1159318e55 ("can: add Renesas R-Car CAN driver")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: Ayumi Nakamichi <ayumi.nakamichi.kf@renesas.com>
---
 drivers/net/can/rcar/rcar_can.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/can/rcar/rcar_can.c b/drivers/net/can/rcar/rcar_can.c
index 00e4533c8bdd..6b4eefb03044 100644
--- a/drivers/net/can/rcar/rcar_can.c
+++ b/drivers/net/can/rcar/rcar_can.c
@@ -846,10 +846,12 @@ static int __maybe_unused rcar_can_suspend(struct device *dev)
 	struct rcar_can_priv *priv = netdev_priv(ndev);
 	u16 ctlr;
 
-	if (netif_running(ndev)) {
-		netif_stop_queue(ndev);
-		netif_device_detach(ndev);
-	}
+	if (!netif_running(ndev))
+		return 0;
+
+	netif_stop_queue(ndev);
+	netif_device_detach(ndev);
+
 	ctlr = readw(&priv->regs->ctlr);
 	ctlr |= RCAR_CAN_CTLR_CANM_HALT;
 	writew(ctlr, &priv->regs->ctlr);
@@ -858,6 +860,7 @@ static int __maybe_unused rcar_can_suspend(struct device *dev)
 	priv->can.state = CAN_STATE_SLEEPING;
 
 	clk_disable(priv->clk);
+
 	return 0;
 }
 
@@ -868,6 +871,9 @@ static int __maybe_unused rcar_can_resume(struct device *dev)
 	u16 ctlr;
 	int err;
 
+	if (!netif_running(ndev))
+		return 0;
+
 	err = clk_enable(priv->clk);
 	if (err) {
 		netdev_err(ndev, "clk_enable() failed, error %d\n", err);
@@ -881,10 +887,9 @@ static int __maybe_unused rcar_can_resume(struct device *dev)
 	writew(ctlr, &priv->regs->ctlr);
 	priv->can.state = CAN_STATE_ERROR_ACTIVE;
 
-	if (netif_running(ndev)) {
-		netif_device_attach(ndev);
-		netif_start_queue(ndev);
-	}
+	netif_device_attach(ndev);
+	netif_start_queue(ndev);
+
 	return 0;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-09-24  7:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-09-21  5:19 [PATCH] can: rcar_can: Fix suspend/resume Yoshihiro Shimoda
2021-09-21 10:38 ` Ulrich Hecht
2021-09-22 15:23   ` Simon Horman
2021-09-24  7:43     ` Yoshihiro Shimoda
2021-09-23 13:30 ` Biju Das

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).