Propagate error value of flexcan_chip_stop(), since this could be called from flexcan_suspend() in some SoCs which support LPSR mode. Signed-off-by: Joakim Zhang <qiangqing.zhang@xxxxxxx> ------ ChangeLog: V3: * new add. --- drivers/net/can/flexcan.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c index 19602b77907f..c5e4b6928dee 100644 --- a/drivers/net/can/flexcan.c +++ b/drivers/net/can/flexcan.c @@ -1263,14 +1263,19 @@ static int flexcan_chip_start(struct net_device *dev) * * this functions is entered with clocks enabled */ -static void flexcan_chip_stop(struct net_device *dev) +static int flexcan_chip_stop(struct net_device *dev) { struct flexcan_priv *priv = netdev_priv(dev); struct flexcan_regs __iomem *regs = priv->regs; + int err; /* freeze + disable module */ - flexcan_chip_freeze(priv); - flexcan_chip_disable(priv); + err = flexcan_chip_freeze(priv); + if (err) + return err; + err = flexcan_chip_disable(priv); + if (err) + goto out_chip_unfreeze; /* Disable all interrupts */ priv->write(0, ®s->imask2); @@ -1278,8 +1283,19 @@ static void flexcan_chip_stop(struct net_device *dev) priv->write(priv->reg_ctrl_default & ~FLEXCAN_CTRL_ERR_ALL, ®s->ctrl); - flexcan_transceiver_disable(priv); + err = flexcan_transceiver_disable(priv); + if (err) + goto out_chip_enable; + priv->can.state = CAN_STATE_STOPPED; + + return 0; + +out_chip_enable: + flexcan_chip_enable(priv); +out_chip_unfreeze: + flexcan_chip_unfreeze(priv); + return err; } static int flexcan_open(struct net_device *dev) -- 2.17.1