]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/spi/omap2_mcspi.c
Merge branch 'drm-ttm-pool' into drm-core-next
[mv-sheeva.git] / drivers / spi / omap2_mcspi.c
index 715c518b1b68f78d820145a13e652f22d4d51dea..d8356af118a8c3ba121dff0eddfd616d9da53192 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/err.h>
 #include <linux/clk.h>
 #include <linux/io.h>
+#include <linux/slab.h>
 
 #include <linux/spi/spi.h>
 
@@ -578,6 +579,7 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,
        struct spi_master *spi_cntrl;
        u32 l = 0, div = 0;
        u8 word_len = spi->bits_per_word;
+       u32 speed_hz = spi->max_speed_hz;
 
        mcspi = spi_master_get_devdata(spi->master);
        spi_cntrl = mcspi->master;
@@ -587,9 +589,12 @@ static int omap2_mcspi_setup_transfer(struct spi_device *spi,
 
        cs->word_len = word_len;
 
-       if (spi->max_speed_hz) {
+       if (t && t->speed_hz)
+               speed_hz = t->speed_hz;
+
+       if (speed_hz) {
                while (div <= 15 && (OMAP2_MCSPI_MAX_FREQ / (1 << div))
-                                       > spi->max_speed_hz)
+                                       > speed_hz)
                        div++;
        } else
                div = 15;
@@ -751,11 +756,13 @@ static void omap2_mcspi_cleanup(struct spi_device *spi)
        mcspi = spi_master_get_devdata(spi->master);
        mcspi_dma = &mcspi->dma_channels[spi->chip_select];
 
-       /* Unlink controller state from context save list */
-       cs = spi->controller_state;
-       list_del(&cs->node);
+       if (spi->controller_state) {
+               /* Unlink controller state from context save list */
+               cs = spi->controller_state;
+               list_del(&cs->node);
 
-       kfree(spi->controller_state);
+               kfree(spi->controller_state);
+       }
 
        if (mcspi_dma->dma_rx_channel != -1) {
                omap_free_dma(mcspi_dma->dma_rx_channel);