diff options
author | Fabio Estevam <fabio.estevam@freescale.com> | 2013-07-11 01:26:49 -0300 |
---|---|---|
committer | Mark Brown <broonie@linaro.org> | 2013-07-15 11:37:56 +0100 |
commit | 83174626ccf897827d2c49f26d9b0b7f74af85cc (patch) | |
tree | 3831a2b814069ed23fe04493f999f9bbff3b02a5 | |
parent | 130b82c047675cf398ac49b7d230288f1b9ac9ad (diff) |
spi: spi-imx: 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.
While at it, fix the order of clk_disable_unprepare calls: clk_ipg should be
disabled first, followed by clk_per.
Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com>
Signed-off-by: Mark Brown <broonie@linaro.org>
-rw-r--r-- | drivers/spi/spi-imx.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 756cd466cfaf..81c7dd2228f9 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -848,8 +848,13 @@ static int spi_imx_probe(struct platform_device *pdev) goto out_master_put; } - clk_prepare_enable(spi_imx->clk_per); - clk_prepare_enable(spi_imx->clk_ipg); + ret = clk_prepare_enable(spi_imx->clk_per); + if (ret) + goto out_master_put; + + ret = clk_prepare_enable(spi_imx->clk_ipg); + if (ret) + goto out_put_per; spi_imx->spi_clk = clk_get_rate(spi_imx->clk_per); @@ -869,8 +874,9 @@ static int spi_imx_probe(struct platform_device *pdev) return ret; out_clk_put: - clk_disable_unprepare(spi_imx->clk_per); clk_disable_unprepare(spi_imx->clk_ipg); +out_put_per: + clk_disable_unprepare(spi_imx->clk_per); out_master_put: spi_master_put(master); @@ -885,8 +891,8 @@ static int spi_imx_remove(struct platform_device *pdev) spi_bitbang_stop(&spi_imx->bitbang); writel(0, spi_imx->base + MXC_CSPICTRL); - clk_disable_unprepare(spi_imx->clk_per); clk_disable_unprepare(spi_imx->clk_ipg); + clk_disable_unprepare(spi_imx->clk_per); spi_master_put(master); return 0; |