spi: make sure all transfer has bits_per_word set
authorLaxman Dewangan <ldewangan@nvidia.com>
Fri, 9 Nov 2012 09:06:45 +0000 (14:36 +0530)
committerMark Brown <broonie@opensource.wolfsonmicro.com>
Fri, 9 Nov 2012 16:42:17 +0000 (16:42 +0000)
When spi client does the spi transfer and does not sets
the bits_per_word for each transfer then set it as default
of spi device in spi core before calling low level transfer.

Removing the similar code from spi-tegra20-slink driver as
it is not required.

Signed-off-by: Laxman Dewangan <ldewangan@nvidia.com>
Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
drivers/spi/spi-tegra20-slink.c
drivers/spi/spi.c

index b8985be81d96224d57550571252c5e6c77959991..07dc7359fb12b1ec8a0d9a75c57c868c3979b00b 100644 (file)
@@ -727,8 +727,7 @@ static int tegra_slink_start_transfer_one(struct spi_device *spi,
        unsigned long command;
        unsigned long command2;
 
-       bits_per_word = t->bits_per_word ? t->bits_per_word :
-                                       spi->bits_per_word;
+       bits_per_word = t->bits_per_word;
        speed = t->speed_hz ? t->speed_hz : spi->max_speed_hz;
        if (!speed)
                speed = tspi->spi_max_frequency;
index 84c2861d6f4dde2a602e44f292c6efbd248c602b..518e5955664c53b13e21d9c448d0e513b6ec7be8 100644 (file)
@@ -1190,6 +1190,7 @@ EXPORT_SYMBOL_GPL(spi_setup);
 static int __spi_async(struct spi_device *spi, struct spi_message *message)
 {
        struct spi_master *master = spi->master;
+       struct spi_transfer *xfer;
 
        /* Half-duplex links include original MicroWire, and ones with
         * only one data pin like SPI_3WIRE (switches direction) or where
@@ -1198,7 +1199,6 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
         */
        if ((master->flags & SPI_MASTER_HALF_DUPLEX)
                        || (spi->mode & SPI_3WIRE)) {
-               struct spi_transfer *xfer;
                unsigned flags = master->flags;
 
                list_for_each_entry(xfer, &message->transfers, transfer_list) {
@@ -1211,6 +1211,15 @@ static int __spi_async(struct spi_device *spi, struct spi_message *message)
                }
        }
 
+       /**
+        * Set transfer bits_per_word as spi device default if it is not
+        * set for this transfer.
+        */
+       list_for_each_entry(xfer, &message->transfers, transfer_list) {
+               if (!xfer->bits_per_word)
+                       xfer->bits_per_word = spi->bits_per_word;
+       }
+
        message->spi = spi;
        message->status = -EINPROGRESS;
        return master->transfer(spi, message);