Commit 6a010b56 authored by Julien Boibessot's avatar Julien Boibessot Committed by Linus Torvalds

spi: fix spi_imx probe oopsing

Corrects spi_imx driver oops during initialization/probing: can't use
drv_data before it's allocated.
Signed-off-by: default avatarJulien Boibessot <julien.boibessot@armadeus.com>
Acked-by: default avatarSascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 7ef9964e
...@@ -1456,7 +1456,7 @@ static int __init spi_imx_probe(struct platform_device *pdev) ...@@ -1456,7 +1456,7 @@ static int __init spi_imx_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct spi_imx_master *platform_info; struct spi_imx_master *platform_info;
struct spi_master *master; struct spi_master *master;
struct driver_data *drv_data = NULL; struct driver_data *drv_data;
struct resource *res; struct resource *res;
int irq, status = 0; int irq, status = 0;
...@@ -1467,14 +1467,6 @@ static int __init spi_imx_probe(struct platform_device *pdev) ...@@ -1467,14 +1467,6 @@ static int __init spi_imx_probe(struct platform_device *pdev)
goto err_no_pdata; goto err_no_pdata;
} }
drv_data->clk = clk_get(&pdev->dev, "perclk2");
if (IS_ERR(drv_data->clk)) {
dev_err(&pdev->dev, "probe - cannot get get\n");
status = PTR_ERR(drv_data->clk);
goto err_no_clk;
}
clk_enable(drv_data->clk);
/* Allocate master with space for drv_data */ /* Allocate master with space for drv_data */
master = spi_alloc_master(dev, sizeof(struct driver_data)); master = spi_alloc_master(dev, sizeof(struct driver_data));
if (!master) { if (!master) {
...@@ -1495,6 +1487,14 @@ static int __init spi_imx_probe(struct platform_device *pdev) ...@@ -1495,6 +1487,14 @@ static int __init spi_imx_probe(struct platform_device *pdev)
drv_data->dummy_dma_buf = SPI_DUMMY_u32; drv_data->dummy_dma_buf = SPI_DUMMY_u32;
drv_data->clk = clk_get(&pdev->dev, "perclk2");
if (IS_ERR(drv_data->clk)) {
dev_err(&pdev->dev, "probe - cannot get clock\n");
status = PTR_ERR(drv_data->clk);
goto err_no_clk;
}
clk_enable(drv_data->clk);
/* Find and map resources */ /* Find and map resources */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) { if (!res) {
...@@ -1630,12 +1630,13 @@ static int __init spi_imx_probe(struct platform_device *pdev) ...@@ -1630,12 +1630,13 @@ static int __init spi_imx_probe(struct platform_device *pdev)
kfree(drv_data->ioarea); kfree(drv_data->ioarea);
err_no_iores: err_no_iores:
spi_master_put(master);
err_no_pdata:
clk_disable(drv_data->clk); clk_disable(drv_data->clk);
clk_put(drv_data->clk); clk_put(drv_data->clk);
err_no_clk: err_no_clk:
spi_master_put(master);
err_no_pdata:
err_no_mem: err_no_mem:
return status; return status;
} }
......
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