]> git.baikalelectronics.ru Git - kernel.git/commitdiff
can: rcar_can: fix suspend/resume
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Fri, 24 Sep 2021 07:55:56 +0000 (16:55 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 27 Oct 2021 07:54:26 +0000 (09:54 +0200)
commit f7c05c3987dcfde9a4e8c2d533db013fabebca0d upstream.

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

Fixes: 108be5a3c99d ("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: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Tested-by: Ayumi Nakamichi <ayumi.nakamichi.kf@renesas.com>
Reviewed-by: Ulrich Hecht <uli+renesas@fpond.eu>
Tested-by: Biju Das <biju.das.jz@bp.renesas.com>
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/can/rcar/rcar_can.c

index bf5adea9c0a38131e33fb46d47ccbbdd32e86926..ac52288fa3bfe6b42ec3cd6eebb4a34382cc27e2 100644 (file)
@@ -848,10 +848,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);
@@ -870,6 +872,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);
@@ -883,10 +888,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;
 }