Merge remote-tracking branch 'spi/topic/core' into spi-next
[cascardo/linux.git] / drivers / spi / spi.c
index d5ee965..0a8f399 100644 (file)
@@ -589,7 +589,6 @@ static int spi_transfer_one_message(struct spi_master *master,
                                    struct spi_message *msg)
 {
        struct spi_transfer *xfer;
-       bool cur_cs = true;
        bool keep_cs = false;
        int ret = 0;
 
@@ -625,8 +624,9 @@ static int spi_transfer_one_message(struct spi_master *master,
                                         &msg->transfers)) {
                                keep_cs = true;
                        } else {
-                               cur_cs = !cur_cs;
-                               spi_set_cs(msg->spi, cur_cs);
+                               spi_set_cs(msg->spi, false);
+                               udelay(10);
+                               spi_set_cs(msg->spi, true);
                        }
                }
 
@@ -753,9 +753,7 @@ static void spi_pump_messages(struct kthread_work *work)
        ret = master->transfer_one_message(master, master->cur_msg);
        if (ret) {
                dev_err(&master->dev,
-                       "failed to transfer one message from queue: %d\n", ret);
-               master->cur_msg->status = ret;
-               spi_finalize_current_message(master);
+                       "failed to transfer one message from queue\n");
                return;
        }
 }
@@ -1617,12 +1615,10 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
 {
        struct spi_master *master = spi->master;
        struct spi_transfer *xfer;
-       int w_size, n_words;
+       int w_size;
 
        if (list_empty(&message->transfers))
                return -EINVAL;
-       if (!message->complete)
-               return -EINVAL;
 
        /* Half-duplex links include original MicroWire, and ones with
         * only one data pin like SPI_3WIRE (switches direction) or where
@@ -1653,12 +1649,13 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
                message->frame_length += xfer->len;
                if (!xfer->bits_per_word)
                        xfer->bits_per_word = spi->bits_per_word;
-               if (!xfer->speed_hz) {
+
+               if (!xfer->speed_hz)
                        xfer->speed_hz = spi->max_speed_hz;
-                       if (master->max_speed_hz &&
-                           xfer->speed_hz > master->max_speed_hz)
-                               xfer->speed_hz = master->max_speed_hz;
-               }
+
+               if (master->max_speed_hz &&
+                   xfer->speed_hz > master->max_speed_hz)
+                       xfer->speed_hz = master->max_speed_hz;
 
                if (master->bits_per_word_mask) {
                        /* Only 32 bits fit in the mask */
@@ -1680,17 +1677,13 @@ static int __spi_validate(struct spi_device *spi, struct spi_message *message)
                else
                        w_size = 4;
 
-               n_words = xfer->len / w_size;
                /* No partial transfers accepted */
-               if (!n_words || xfer->len % w_size)
+               if (xfer->len % w_size)
                        return -EINVAL;
 
                if (xfer->speed_hz && master->min_speed_hz &&
                    xfer->speed_hz < master->min_speed_hz)
                        return -EINVAL;
-               if (xfer->speed_hz && master->max_speed_hz &&
-                   xfer->speed_hz > master->max_speed_hz)
-                       return -EINVAL;
 
                if (xfer->tx_buf && !xfer->tx_nbits)
                        xfer->tx_nbits = SPI_NBITS_SINGLE;