Merge remote-tracking branch 'spi/topic/msglen' into spi-next
authorMark Brown <broonie@linaro.org>
Sun, 1 Sep 2013 12:48:58 +0000 (13:48 +0100)
committerMark Brown <broonie@linaro.org>
Sun, 1 Sep 2013 12:48:58 +0000 (13:48 +0100)
1  2 
drivers/spi/spi.c
include/linux/spi/spi.h

diff --combined drivers/spi/spi.c
@@@ -774,7 -774,7 +774,7 @@@ static int spi_queued_transfer(struct s
        msg->status = -EINPROGRESS;
  
        list_add_tail(&msg->queue, &master->queue);
 -      if (master->running && !master->busy)
 +      if (!master->busy)
                queue_kthread_work(&master->kworker, &master->pump_messages);
  
        spin_unlock_irqrestore(&master->queue_lock, flags);
@@@ -1169,7 -1169,7 +1169,7 @@@ int spi_register_master(struct spi_mast
        else {
                status = spi_master_initialize_queue(master);
                if (status) {
 -                      device_unregister(&master->dev);
 +                      device_del(&master->dev);
                        goto done;
                }
        }
@@@ -1351,11 -1351,6 +1351,11 @@@ static int __spi_async(struct spi_devic
        struct spi_master *master = spi->master;
        struct spi_transfer *xfer;
  
 +      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
         * either MOSI or MISO is missing.  They can also be caused by
         * it is not set for this transfer.
         */
        list_for_each_entry(xfer, &message->transfers, transfer_list) {
+               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->bits_per_word_mask) {
                        /* Only 32 bits fit in the mask */
                        if (xfer->bits_per_word > 32)
                                        BIT(xfer->bits_per_word - 1)))
                                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;
        }
  
        message->spi = spi;
diff --combined include/linux/spi/spi.h
@@@ -233,8 -233,6 +233,8 @@@ static inline void spi_unregister_drive
   *    suported. If set, the SPI core will reject any transfer with an
   *    unsupported bits_per_word. If not set, this value is simply ignored,
   *    and it's up to the individual driver to perform any validation.
 + * @min_speed_hz: Lowest supported transfer speed
 + * @max_speed_hz: Highest supported transfer speed
   * @flags: other constraints relevant to this driver
   * @bus_lock_spinlock: spinlock for SPI bus locking
   * @bus_lock_mutex: mutex for SPI bus locking
@@@ -311,13 -309,9 +311,13 @@@ struct spi_master 
        /* bitmask of supported bits_per_word for transfers */
        u32                     bits_per_word_mask;
  #define SPI_BPW_MASK(bits) BIT((bits) - 1)
 -#define SPI_BIT_MASK(bits) (((bits) == 32) ? ~0UL : (BIT(bits) - 1))
 +#define SPI_BIT_MASK(bits) (((bits) == 32) ? ~0U : (BIT(bits) - 1))
  #define SPI_BPW_RANGE_MASK(min, max) (SPI_BIT_MASK(max) - SPI_BIT_MASK(min - 1))
  
 +      /* limits on transfer speed */
 +      u32                     min_speed_hz;
 +      u32                     max_speed_hz;
 +
        /* other constraints relevant to this driver */
        u16                     flags;
  #define SPI_MASTER_HALF_DUPLEX        BIT(0)          /* can't do full duplex */
@@@ -584,6 -578,7 +584,7 @@@ struct spi_message 
        /* completion is reported through a callback */
        void                    (*complete)(void *context);
        void                    *context;
+       unsigned                frame_length;
        unsigned                actual_length;
        int                     status;