Merge branch 'for-4.3/sg' of git://git.kernel.dk/linux-block
[firefly-linux-kernel-4.4.55.git] / drivers / spi / spi-omap2-mcspi.c
index 58673841286c335adc123d5200c1a0f128ecab04..3d09e0b69b73241c58d50e788dbdaf5cd16bf7ea 100644 (file)
@@ -245,6 +245,7 @@ static void omap2_mcspi_set_enable(const struct spi_device *spi, int enable)
 
 static void omap2_mcspi_set_cs(struct spi_device *spi, bool enable)
 {
+       struct omap2_mcspi *mcspi = spi_master_get_devdata(spi->master);
        u32 l;
 
        /* The controller handles the inverted chip selects
@@ -255,6 +256,12 @@ static void omap2_mcspi_set_cs(struct spi_device *spi, bool enable)
                enable = !enable;
 
        if (spi->controller_state) {
+               int err = pm_runtime_get_sync(mcspi->dev);
+               if (err < 0) {
+                       dev_err(mcspi->dev, "failed to get sync: %d\n", err);
+                       return;
+               }
+
                l = mcspi_cached_chconf0(spi);
 
                if (enable)
@@ -263,6 +270,9 @@ static void omap2_mcspi_set_cs(struct spi_device *spi, bool enable)
                        l |= OMAP2_MCSPI_CHCONF_FORCE;
 
                mcspi_write_chconf0(spi, l);
+
+               pm_runtime_mark_last_busy(mcspi->dev);
+               pm_runtime_put_autosuspend(mcspi->dev);
        }
 }