spi: pxa2xx: Use local struct spi_master pointer in pump_transfers()
[linux-2.6-microblaze.git] / drivers / spi / spi-pxa2xx.c
index 86138e4..e5c457a 100644 (file)
@@ -570,9 +570,8 @@ static void giveback(struct driver_data *drv_data)
                /* see if the next and current messages point
                 * to the same chip
                 */
-               if (next_msg && next_msg->spi != msg->spi)
-                       next_msg = NULL;
-               if (!next_msg || msg->state == ERROR_STATE)
+               if ((next_msg && next_msg->spi != msg->spi) ||
+                   msg->state == ERROR_STATE)
                        cs_deassert(drv_data);
        }
 
@@ -916,6 +915,7 @@ static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data,
 static void pump_transfers(unsigned long data)
 {
        struct driver_data *drv_data = (struct driver_data *)data;
+       struct spi_master *master = drv_data->master;
        struct spi_message *message = NULL;
        struct spi_transfer *transfer = NULL;
        struct spi_transfer *previous = NULL;
@@ -928,6 +928,7 @@ static void pump_transfers(unsigned long data)
        u32 dma_thresh = drv_data->cur_chip->dma_threshold;
        u32 dma_burst = drv_data->cur_chip->dma_burst_size;
        u32 change_mask = pxa2xx_spi_get_ssrc1_change_mask(drv_data);
+       int err;
 
        /* Get current state information */
        message = drv_data->cur_msg;
@@ -1047,7 +1048,12 @@ static void pump_transfers(unsigned long data)
                /* Ensure we have the correct interrupt handler */
                drv_data->transfer_handler = pxa2xx_spi_dma_transfer;
 
-               pxa2xx_spi_dma_prepare(drv_data, dma_burst);
+               err = pxa2xx_spi_dma_prepare(drv_data, dma_burst);
+               if (err) {
+                       message->status = err;
+                       giveback(drv_data);
+                       return;
+               }
 
                /* Clear status and start DMA engine */
                cr1 = chip->cr1 | dma_thresh | drv_data->dma_cr1;
@@ -1067,12 +1073,12 @@ static void pump_transfers(unsigned long data)
        cr0 = pxa2xx_configure_sscr0(drv_data, clk_div, bits);
        if (!pxa25x_ssp_comp(drv_data))
                dev_dbg(&message->spi->dev, "%u Hz actual, %s\n",
-                       drv_data->master->max_speed_hz
+                       master->max_speed_hz
                                / (1 + ((cr0 & SSCR0_SCR(0xfff)) >> 8)),
                        drv_data->dma_mapped ? "DMA" : "PIO");
        else
                dev_dbg(&message->spi->dev, "%u Hz actual, %s\n",
-                       drv_data->master->max_speed_hz / 2
+                       master->max_speed_hz / 2
                                / (1 + ((cr0 & SSCR0_SCR(0x0ff)) >> 8)),
                        drv_data->dma_mapped ? "DMA" : "PIO");
 
@@ -1235,7 +1241,7 @@ static int setup(struct spi_device *spi)
                        chip->frm = spi->chip_select;
                } else
                        chip->gpio_cs = -1;
-               chip->enable_dma = 0;
+               chip->enable_dma = drv_data->master_info->enable_dma;
                chip->timeout = TIMOUT_DFLT;
        }
 
@@ -1254,17 +1260,9 @@ static int setup(struct spi_device *spi)
                        tx_hi_thres = chip_info->tx_hi_threshold;
                if (chip_info->rx_threshold)
                        rx_thres = chip_info->rx_threshold;
-               chip->enable_dma = drv_data->master_info->enable_dma;
                chip->dma_threshold = 0;
                if (chip_info->enable_loopback)
                        chip->cr1 = SSCR1_LBM;
-       } else if (ACPI_HANDLE(&spi->dev)) {
-               /*
-                * Slave devices enumerated from ACPI namespace don't
-                * usually have chip_info but we still might want to use
-                * DMA with them.
-                */
-               chip->enable_dma = drv_data->master_info->enable_dma;
        }
 
        chip->lpss_rx_threshold = SSIRF_RxThresh(rx_thres);
@@ -1543,7 +1541,6 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
        drv_data->pdev = pdev;
        drv_data->ssp = ssp;
 
-       master->dev.parent = &pdev->dev;
        master->dev.of_node = pdev->dev.of_node;
        /* the spi->mode bits understood by this driver: */
        master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LOOP;
@@ -1556,6 +1553,7 @@ static int pxa2xx_spi_probe(struct platform_device *pdev)
        master->unprepare_transfer_hardware = pxa2xx_spi_unprepare_transfer;
        master->fw_translate_cs = pxa2xx_spi_fw_translate_cs;
        master->auto_runtime_pm = true;
+       master->flags = SPI_MASTER_MUST_RX | SPI_MASTER_MUST_TX;
 
        drv_data->ssp_type = ssp->type;