]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/spi/omap2_mcspi.c
omap2_mcspi: Flush posted writes
[karo-tx-linux.git] / drivers / spi / omap2_mcspi.c
index 715c518b1b68f78d820145a13e652f22d4d51dea..581bd2169d7b2404364bc75a704b5008c825d062 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>
 
@@ -203,6 +204,7 @@ static inline void mcspi_write_chconf0(const struct spi_device *spi, u32 val)
 
        cs->chconf0 = val;
        mcspi_write_cs_reg(spi, OMAP2_MCSPI_CHCONF0, val);
+       mcspi_read_cs_reg(spi, OMAP2_MCSPI_CHCONF0);
 }
 
 static void omap2_mcspi_set_dma_req(const struct spi_device *spi,
@@ -578,6 +580,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 +590,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 +757,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);