aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorJulien Boibessot <julien.boibessot@free.fr>2008-12-01 16:13:55 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2008-12-01 22:55:24 -0500
commit6a010b56e9bd2fdb32efd153e1a08305949b6b53 (patch)
treee4caf907a10b497f0040255a8b3ece28c0dc2b27 /drivers/spi
parent7ef9964e6d1b911b78709f144000aacadd0ebc21 (diff)
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: Julien Boibessot <julien.boibessot@armadeus.com> Acked-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi_imx.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/drivers/spi/spi_imx.c b/drivers/spi/spi_imx.c
index 0b4db0ce78d6..269a55ec52ef 100644
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -1456,7 +1456,7 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1456 struct device *dev = &pdev->dev; 1456 struct device *dev = &pdev->dev;
1457 struct spi_imx_master *platform_info; 1457 struct spi_imx_master *platform_info;
1458 struct spi_master *master; 1458 struct spi_master *master;
1459 struct driver_data *drv_data = NULL; 1459 struct driver_data *drv_data;
1460 struct resource *res; 1460 struct resource *res;
1461 int irq, status = 0; 1461 int irq, status = 0;
1462 1462
@@ -1467,14 +1467,6 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1467 goto err_no_pdata; 1467 goto err_no_pdata;
1468 } 1468 }
1469 1469
1470 drv_data->clk = clk_get(&pdev->dev, "perclk2");
1471 if (IS_ERR(drv_data->clk)) {
1472 dev_err(&pdev->dev, "probe - cannot get get\n");
1473 status = PTR_ERR(drv_data->clk);
1474 goto err_no_clk;
1475 }
1476 clk_enable(drv_data->clk);
1477
1478 /* Allocate master with space for drv_data */ 1470 /* Allocate master with space for drv_data */
1479 master = spi_alloc_master(dev, sizeof(struct driver_data)); 1471 master = spi_alloc_master(dev, sizeof(struct driver_data));
1480 if (!master) { 1472 if (!master) {
@@ -1495,6 +1487,14 @@ static int __init spi_imx_probe(struct platform_device *pdev)
1495 1487
1496 drv_data->dummy_dma_buf = SPI_DUMMY_u32; 1488 drv_data->dummy_dma_buf = SPI_DUMMY_u32;
1497 1489
1490 drv_data->clk = clk_get(&pdev->dev, "perclk2");
1491 if (IS_ERR(drv_data->clk)) {
1492 dev_err(&pdev->dev, "probe - cannot get clock\n");
1493 status = PTR_ERR(drv_data->clk);
1494 goto err_no_clk;
1495 }
1496 clk_enable(drv_data->clk);
1497
1498 /* Find and map resources */ 1498 /* Find and map resources */
1499 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1499 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
1500 if (!res) { 1500 if (!res) {
@@ -1630,12 +1630,13 @@ err_no_iomap:
1630 kfree(drv_data->ioarea); 1630 kfree(drv_data->ioarea);
1631 1631
1632err_no_iores: 1632err_no_iores:
1633 spi_master_put(master);
1634
1635err_no_pdata:
1636 clk_disable(drv_data->clk); 1633 clk_disable(drv_data->clk);
1637 clk_put(drv_data->clk); 1634 clk_put(drv_data->clk);
1635
1638err_no_clk: 1636err_no_clk:
1637 spi_master_put(master);
1638
1639err_no_pdata:
1639err_no_mem: 1640err_no_mem:
1640 return status; 1641 return status;
1641} 1642}