Commit aa10181b authored by Fabio Estevam's avatar Fabio Estevam Committed by Marc Kleine-Budde

can: flexcan: Check the return value from clk_prepare_enable()

clk_prepare_enable() may fail, so let's check its return value and propagate it
in the case of error.
Signed-off-by: default avatarFabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: default avatarMarc Kleine-Budde <mkl@pengutronix.de>
parent 933e4af4
...@@ -850,12 +850,17 @@ static int flexcan_open(struct net_device *dev) ...@@ -850,12 +850,17 @@ static int flexcan_open(struct net_device *dev)
struct flexcan_priv *priv = netdev_priv(dev); struct flexcan_priv *priv = netdev_priv(dev);
int err; int err;
clk_prepare_enable(priv->clk_ipg); err = clk_prepare_enable(priv->clk_ipg);
clk_prepare_enable(priv->clk_per); if (err)
return err;
err = clk_prepare_enable(priv->clk_per);
if (err)
goto out_disable_ipg;
err = open_candev(dev); err = open_candev(dev);
if (err) if (err)
goto out; goto out_disable_per;
err = request_irq(dev->irq, flexcan_irq, IRQF_SHARED, dev->name, dev); err = request_irq(dev->irq, flexcan_irq, IRQF_SHARED, dev->name, dev);
if (err) if (err)
...@@ -875,8 +880,9 @@ static int flexcan_open(struct net_device *dev) ...@@ -875,8 +880,9 @@ static int flexcan_open(struct net_device *dev)
out_close: out_close:
close_candev(dev); close_candev(dev);
out: out_disable_per:
clk_disable_unprepare(priv->clk_per); clk_disable_unprepare(priv->clk_per);
out_disable_ipg:
clk_disable_unprepare(priv->clk_ipg); clk_disable_unprepare(priv->clk_ipg);
return err; return err;
...@@ -933,8 +939,13 @@ static int register_flexcandev(struct net_device *dev) ...@@ -933,8 +939,13 @@ static int register_flexcandev(struct net_device *dev)
struct flexcan_regs __iomem *regs = priv->base; struct flexcan_regs __iomem *regs = priv->base;
u32 reg, err; u32 reg, err;
clk_prepare_enable(priv->clk_ipg); err = clk_prepare_enable(priv->clk_ipg);
clk_prepare_enable(priv->clk_per); if (err)
return err;
err = clk_prepare_enable(priv->clk_per);
if (err)
goto out_disable_ipg;
/* select "bus clock", chip must be disabled */ /* select "bus clock", chip must be disabled */
flexcan_chip_disable(priv); flexcan_chip_disable(priv);
...@@ -959,15 +970,16 @@ static int register_flexcandev(struct net_device *dev) ...@@ -959,15 +970,16 @@ static int register_flexcandev(struct net_device *dev)
if (!(reg & FLEXCAN_MCR_FEN)) { if (!(reg & FLEXCAN_MCR_FEN)) {
netdev_err(dev, "Could not enable RX FIFO, unsupported core\n"); netdev_err(dev, "Could not enable RX FIFO, unsupported core\n");
err = -ENODEV; err = -ENODEV;
goto out; goto out_disable_per;
} }
err = register_candev(dev); err = register_candev(dev);
out: out_disable_per:
/* disable core and turn off clocks */ /* disable core and turn off clocks */
flexcan_chip_disable(priv); flexcan_chip_disable(priv);
clk_disable_unprepare(priv->clk_per); clk_disable_unprepare(priv->clk_per);
out_disable_ipg:
clk_disable_unprepare(priv->clk_ipg); clk_disable_unprepare(priv->clk_ipg);
return err; return err;
......
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