Commit f7c05c39 authored by Yoshihiro Shimoda's avatar Yoshihiro Shimoda Committed by Marc Kleine-Budde

can: rcar_can: fix suspend/resume

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

Fixes: fd115931 ("can: add Renesas R-Car CAN driver")
Link: https://lore.kernel.org/all/20210924075556.223685-1-yoshihiro.shimoda.uh@renesas.com
Cc: stable@vger.kernel.org
Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: default avatarAyumi Nakamichi <ayumi.nakamichi.kf@renesas.com>
Reviewed-by: default avatarUlrich Hecht <uli+renesas@fpond.eu>
Tested-by: default avatarBiju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 43a08c3b
...@@ -846,10 +846,12 @@ static int __maybe_unused rcar_can_suspend(struct device *dev) ...@@ -846,10 +846,12 @@ static int __maybe_unused rcar_can_suspend(struct device *dev)
struct rcar_can_priv *priv = netdev_priv(ndev); struct rcar_can_priv *priv = netdev_priv(ndev);
u16 ctlr; u16 ctlr;
if (netif_running(ndev)) { if (!netif_running(ndev))
return 0;
netif_stop_queue(ndev); netif_stop_queue(ndev);
netif_device_detach(ndev); netif_device_detach(ndev);
}
ctlr = readw(&priv->regs->ctlr); ctlr = readw(&priv->regs->ctlr);
ctlr |= RCAR_CAN_CTLR_CANM_HALT; ctlr |= RCAR_CAN_CTLR_CANM_HALT;
writew(ctlr, &priv->regs->ctlr); writew(ctlr, &priv->regs->ctlr);
...@@ -868,6 +870,9 @@ static int __maybe_unused rcar_can_resume(struct device *dev) ...@@ -868,6 +870,9 @@ static int __maybe_unused rcar_can_resume(struct device *dev)
u16 ctlr; u16 ctlr;
int err; int err;
if (!netif_running(ndev))
return 0;
err = clk_enable(priv->clk); err = clk_enable(priv->clk);
if (err) { if (err) {
netdev_err(ndev, "clk_enable() failed, error %d\n", err); netdev_err(ndev, "clk_enable() failed, error %d\n", err);
...@@ -881,10 +886,9 @@ static int __maybe_unused rcar_can_resume(struct device *dev) ...@@ -881,10 +886,9 @@ static int __maybe_unused rcar_can_resume(struct device *dev)
writew(ctlr, &priv->regs->ctlr); writew(ctlr, &priv->regs->ctlr);
priv->can.state = CAN_STATE_ERROR_ACTIVE; priv->can.state = CAN_STATE_ERROR_ACTIVE;
if (netif_running(ndev)) {
netif_device_attach(ndev); netif_device_attach(ndev);
netif_start_queue(ndev); netif_start_queue(ndev);
}
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment