VMware Balloon driver
[safe/jmp/linux-2.6] / drivers / spi / au1550_spi.c
index b02f25c..3c9ade6 100644 (file)
@@ -23,6 +23,7 @@
 
 #include <linux/init.h>
 #include <linux/interrupt.h>
+#include <linux/slab.h>
 #include <linux/errno.h>
 #include <linux/device.h>
 #include <linux/platform_device.h>
@@ -237,8 +238,14 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
        unsigned bpw, hz;
        u32 cfg, stat;
 
-       bpw = t ? t->bits_per_word : spi->bits_per_word;
-       hz = t ? t->speed_hz : spi->max_speed_hz;
+       bpw = spi->bits_per_word;
+       hz = spi->max_speed_hz;
+       if (t) {
+               if (t->bits_per_word)
+                       bpw = t->bits_per_word;
+               if (t->speed_hz)
+                       hz = t->speed_hz;
+       }
 
        if (bpw < 4 || bpw > 24) {
                dev_err(&spi->dev, "setupxfer: invalid bits_per_word=%d\n",
@@ -284,27 +291,16 @@ static int au1550_spi_setupxfer(struct spi_device *spi, struct spi_transfer *t)
        return 0;
 }
 
-/* the spi->mode bits understood by this driver: */
-#define MODEBITS (SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST)
-
 static int au1550_spi_setup(struct spi_device *spi)
 {
        struct au1550_spi *hw = spi_master_get_devdata(spi->master);
 
-       if (spi->bits_per_word == 0)
-               spi->bits_per_word = 8;
        if (spi->bits_per_word < 4 || spi->bits_per_word > 24) {
                dev_err(&spi->dev, "setup: invalid bits_per_word=%d\n",
                        spi->bits_per_word);
                return -EINVAL;
        }
 
-       if (spi->mode & ~MODEBITS) {
-               dev_dbg(&spi->dev, "setup: unsupported mode bits %x\n",
-                       spi->mode & ~MODEBITS);
-               return -EINVAL;
-       }
-
        if (spi->max_speed_hz == 0)
                spi->max_speed_hz = hw->freq_max;
        if (spi->max_speed_hz > hw->freq_max
@@ -417,11 +413,13 @@ static int au1550_spi_dma_txrxb(struct spi_device *spi, struct spi_transfer *t)
        }
 
        /* put buffers on the ring */
-       res = au1xxx_dbdma_put_dest(hw->dma_rx_ch, hw->rx, t->len);
+       res = au1xxx_dbdma_put_dest(hw->dma_rx_ch, virt_to_phys(hw->rx),
+                                   t->len, DDMA_FLAGS_IE);
        if (!res)
                dev_err(hw->dev, "rx dma put dest error\n");
 
-       res = au1xxx_dbdma_put_source(hw->dma_tx_ch, (void *)hw->tx, t->len);
+       res = au1xxx_dbdma_put_source(hw->dma_tx_ch, virt_to_phys(hw->tx),
+                                     t->len, DDMA_FLAGS_IE);
        if (!res)
                dev_err(hw->dev, "tx dma put source error\n");
 
@@ -781,6 +779,9 @@ static int __init au1550_spi_probe(struct platform_device *pdev)
                goto err_nomem;
        }
 
+       /* the spi->mode bits understood by this driver: */
+       master->mode_bits = SPI_CPOL | SPI_CPHA | SPI_CS_HIGH | SPI_LSB_FIRST;
+
        hw = spi_master_get_devdata(master);
 
        hw->master = spi_master_get(master);