Blackfin SPI Driver: remove useless <asm/cplbinit.h>
[safe/jmp/linux-2.6] / drivers / spi / spi_imx.c
index bd0729b..0480d8b 100644 (file)
 
 #include <asm/io.h>
 #include <asm/irq.h>
-#include <asm/hardware.h>
 #include <asm/delay.h>
 
-#include <asm/arch/hardware.h>
-#include <asm/arch/imx-dma.h>
-#include <asm/arch/spi_imx.h>
+#include <mach/hardware.h>
+#include <mach/imx-dma.h>
+#include <mach/spi_imx.h>
 
 /*-------------------------------------------------------------------------*/
 /* SPI Registers offsets from peripheral base address */
@@ -491,7 +490,7 @@ static int map_dma_buffers(struct driver_data *drv_data)
                                                        buf,
                                                        drv_data->tx_map_len,
                                                        DMA_TO_DEVICE);
-                       if (dma_mapping_error(drv_data->tx_dma))
+                       if (dma_mapping_error(dev, drv_data->tx_dma))
                                return -1;
 
                        drv_data->tx_dma_needs_unmap = 1;
@@ -507,20 +506,6 @@ static int map_dma_buffers(struct driver_data *drv_data)
        if (!IS_DMA_ALIGNED(drv_data->rx) || !IS_DMA_ALIGNED(drv_data->tx))
                return -1;
 
-       /* NULL rx means write-only transfer and no map needed
-          since rx DMA will not be used */
-       if (drv_data->rx) {
-               buf = drv_data->rx;
-               drv_data->rx_dma = dma_map_single(
-                                       dev,
-                                       buf,
-                                       drv_data->len,
-                                       DMA_FROM_DEVICE);
-               if (dma_mapping_error(drv_data->rx_dma))
-                       return -1;
-               drv_data->rx_dma_needs_unmap = 1;
-       }
-
        if (drv_data->tx == NULL) {
                /* Read only message --> use drv_data->dummy_dma_buf for dummy
                   writes to achive reads */
@@ -534,18 +519,31 @@ static int map_dma_buffers(struct driver_data *drv_data)
                                        buf,
                                        drv_data->tx_map_len,
                                        DMA_TO_DEVICE);
-       if (dma_mapping_error(drv_data->tx_dma)) {
-               if (drv_data->rx_dma) {
-                       dma_unmap_single(dev,
-                                       drv_data->rx_dma,
-                                       drv_data->len,
-                                       DMA_FROM_DEVICE);
-                       drv_data->rx_dma_needs_unmap = 0;
-               }
+       if (dma_mapping_error(dev, drv_data->tx_dma))
                return -1;
-       }
        drv_data->tx_dma_needs_unmap = 1;
 
+       /* NULL rx means write-only transfer and no map needed
+        * since rx DMA will not be used */
+       if (drv_data->rx) {
+               buf = drv_data->rx;
+               drv_data->rx_dma = dma_map_single(dev,
+                                               buf,
+                                               drv_data->len,
+                                               DMA_FROM_DEVICE);
+               if (dma_mapping_error(dev, drv_data->rx_dma)) {
+                       if (drv_data->tx_dma) {
+                               dma_unmap_single(dev,
+                                               drv_data->tx_dma,
+                                               drv_data->tx_map_len,
+                                               DMA_TO_DEVICE);
+                               drv_data->tx_dma_needs_unmap = 0;
+                       }
+                       return -1;
+               }
+               drv_data->rx_dma_needs_unmap = 1;
+       }
+
        return 0;
 }
 
@@ -1383,7 +1381,7 @@ static int __init init_queue(struct driver_data *drv_data)
 
        INIT_WORK(&drv_data->work, pump_messages);
        drv_data->workqueue = create_singlethread_workqueue(
-                                       drv_data->master->dev.parent->bus_id);
+                               dev_name(drv_data->master->dev.parent));
        if (drv_data->workqueue == NULL)
                return -EBUSY;
 
@@ -1458,7 +1456,7 @@ static int __init spi_imx_probe(struct platform_device *pdev)
        struct device *dev = &pdev->dev;
        struct spi_imx_master *platform_info;
        struct spi_master *master;
-       struct driver_data *drv_data = NULL;
+       struct driver_data *drv_data;
        struct resource *res;
        int irq, status = 0;
 
@@ -1469,14 +1467,6 @@ static int __init spi_imx_probe(struct platform_device *pdev)
                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 */
        master = spi_alloc_master(dev, sizeof(struct driver_data));
        if (!master) {
@@ -1497,6 +1487,14 @@ static int __init spi_imx_probe(struct platform_device *pdev)
 
        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 */
        res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
        if (!res) {
@@ -1527,7 +1525,8 @@ static int __init spi_imx_probe(struct platform_device *pdev)
                status = -ENODEV;
                goto err_no_irqres;
        }
-       status = request_irq(irq, spi_int, IRQF_DISABLED, dev->bus_id, drv_data);
+       status = request_irq(irq, spi_int, IRQF_DISABLED,
+                            dev_name(dev), drv_data);
        if (status < 0) {
                dev_err(&pdev->dev, "probe - cannot get IRQ (%d)\n", status);
                goto err_no_irqres;
@@ -1538,24 +1537,24 @@ static int __init spi_imx_probe(struct platform_device *pdev)
        drv_data->rx_channel = -1;
        if (platform_info->enable_dma) {
                /* Get rx DMA channel */
-               status = imx_dma_request_by_prio(&drv_data->rx_channel,
-                       "spi_imx_rx", DMA_PRIO_HIGH);
-               if (status < 0) {
+               drv_data->rx_channel = imx_dma_request_by_prio("spi_imx_rx",
+                                                              DMA_PRIO_HIGH);
+               if (drv_data->rx_channel < 0) {
                        dev_err(dev,
                                "probe - problem (%d) requesting rx channel\n",
-                               status);
+                               drv_data->rx_channel);
                        goto err_no_rxdma;
                } else
                        imx_dma_setup_handlers(drv_data->rx_channel, NULL,
                                                dma_err_handler, drv_data);
 
                /* Get tx DMA channel */
-               status = imx_dma_request_by_prio(&drv_data->tx_channel,
-                                               "spi_imx_tx", DMA_PRIO_MEDIUM);
-               if (status < 0) {
+               drv_data->tx_channel = imx_dma_request_by_prio("spi_imx_tx",
+                                                              DMA_PRIO_MEDIUM);
+               if (drv_data->tx_channel < 0) {
                        dev_err(dev,
                                "probe - problem (%d) requesting tx channel\n",
-                               status);
+                               drv_data->tx_channel);
                        imx_dma_free(drv_data->rx_channel);
                        goto err_no_txdma;
                } else
@@ -1632,12 +1631,13 @@ err_no_iomap:
        kfree(drv_data->ioarea);
 
 err_no_iores:
-       spi_master_put(master);
-
-err_no_pdata:
        clk_disable(drv_data->clk);
        clk_put(drv_data->clk);
+
 err_no_clk:
+       spi_master_put(master);
+
+err_no_pdata:
 err_no_mem:
        return status;
 }