atmel_spi: fix warning In function 'atmel_spi_dma_map_xfer'
[pandora-kernel.git] / drivers / spi / atmel_spi.c
index c4e0442..a067046 100644 (file)
@@ -352,8 +352,12 @@ atmel_spi_dma_map_xfer(struct atmel_spi *as, struct spi_transfer *xfer)
 
        xfer->tx_dma = xfer->rx_dma = INVALID_DMA_ADDRESS;
        if (xfer->tx_buf) {
+               /* tx_buf is a const void* where we need a void * for the dma
+                * mapping */
+               void *nonconst_tx = (void *)xfer->tx_buf;
+
                xfer->tx_dma = dma_map_single(dev,
-                               (void *) xfer->tx_buf, xfer->len,
+                               nonconst_tx, xfer->len,
                                DMA_TO_DEVICE);
                if (dma_mapping_error(dev, xfer->tx_dma))
                        return -ENOMEM;
@@ -654,6 +658,8 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
        struct spi_transfer     *xfer;
        unsigned long           flags;
        struct device           *controller = spi->master->dev.parent;
+       u8                      bits;
+       struct atmel_spi_device *asd;
 
        as = spi_master_get_devdata(spi->master);
 
@@ -672,8 +678,18 @@ static int atmel_spi_transfer(struct spi_device *spi, struct spi_message *msg)
                        return -EINVAL;
                }
 
+               if (xfer->bits_per_word) {
+                       asd = spi->controller_state;
+                       bits = (asd->csr >> 4) & 0xf;
+                       if (bits != xfer->bits_per_word - 8) {
+                               dev_dbg(&spi->dev, "you can't yet change "
+                                        "bits_per_word in transfers\n");
+                               return -ENOPROTOOPT;
+                       }
+               }
+
                /* FIXME implement these protocol options!! */
-               if (xfer->bits_per_word || xfer->speed_hz) {
+               if (xfer->speed_hz) {
                        dev_dbg(&spi->dev, "no protocol options yet\n");
                        return -ENOPROTOOPT;
                }